微服务,微架构[十一]springboot模板页面thymeleaf
来源:互联网 发布:数据库设置主键的语句 编辑:程序博客网 时间:2024/06/08 19:30
springboot可以集成很多模板文件来实现访问页面,今天我们主要介绍thymeleaf的集成方式,很多集成模板页面都是大同小异,也是springboot推荐使用的页面方式
一、加入依赖pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
二、控制器访问页面
package com.didispace.web;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;/**** @author e生态* @version 1.0.0* @blog http://blog.csdn.net/ysl_228**/@Controllerpublic class HelloController { @ResponseBody @RequestMapping("/hello") public String hello() { return "Hello World"; } @RequestMapping("/") public String index(ModelMap map) { map.addAttribute("host", "http://blog.csdn.net/ysl_228"); map.addAttribute("test", "1234"); return "index"; } @RequestMapping("/mvc") public String index(Model model) { model.addAttribute("host", "http://blog.csdn.net/ysl_228"); model.addAttribute("test", "1234"); return "mvc"; }}
三、访问页面,默认资源访问目录resource/template/index.html
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" /> <title></title></head><body><h1 th:text="${host}">Hello World</h1></body></html>
阅读全文
0 0
- 微服务,微架构[十一]springboot模板页面thymeleaf
- 微服务,微架构[十一]springboot模板页面velocity
- 微服务,微架构[十]springboot模板页面freemarker
- SpringBoot开始微服务架构
- SpringBoot Thymeleaf 模板引擎
- SpringBoot-thymeleaf模板集成
- springboot整合thymeleaf模板
- SpringBoot整合thymeleaf模板
- SpringBoot集成Thymeleaf模板
- SpringBoot 开发使用thymeleaf模板开发html页面
- 微服务之集成thymeleaf访问html页面/静态页面
- 微服务,微架构[一]之springboot[helloWorld]
- 微服务,微架构[二]之springboot集成jdbc
- 微服务,微架构[四]之springboot集成Redis缓存
- 微服务,微架构[五]之springboot读取properties文件
- 微服务,微架构[六]之springboot集成mybatis
- 微服务,微架构[零]springboot入门介绍
- 微服务,微架构[七]之springboot异常处理
- Complex类的实现过程
- request.getContextPath()获取的是什么路径?
- Xpath总结
- 使用Sketch进行iOS开发
- CountDownLatch
- 微服务,微架构[十一]springboot模板页面thymeleaf
- java构造函数详解
- 读文献笔记:汇率政策新共识与“”中间制度消亡论“”
- Nested Segments CodeForces 652D 树状数组+离散化
- [OpenGL 超级宝典][笔记] 8.1 PBO介绍与用法
- 内省操作javabean
- Java中String对象创建机制详解
- 基于Scrapy分布式爬虫的开发与设计
- [BZOJ]1192: [HNOI2006]鬼谷子的钱袋