SpringBoot使用thymeleaf的简单记录
来源:互联网 发布:js对象深拷贝 编辑:程序博客网 时间:2024/06/05 10:02
一、引入jar包
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
二、thymeleaf配置
在application.xml中配置如下
#模板的配置#关闭缓存,实时显示开发效果spring.thymeleaf.cache=false#指定类型spring.thymeleaf.content-type=text/html#指定编码spring.thymeleaf.encoding=UTF-8#指定模板的位置,默认/template/spring.thymeleaf.prefix=classpath:/templates/spring.thymeleaf.mode=HTML5#指定后缀spring.thymeleaf.suffix=.html
三、编写代码和页面
示例controller
import org.springframework.ui.Model;@Controllerpublic class IndexController { @GetMapping(value = "/index") public String index(Model model) { String name = "百度"; String url = "http://www.baidu.com"; model.addAttribute("name", name); model.addAttribute("url", url); return "index"; }}
页面:
<!DOCTYPE HTML><html xmlns:th="http://www.thymeleaf.org"> <head> <title>Index</title> </head> <body> <a th:text="${name}" th:href="${url}"></a> </body></html>
标签使用方法比较简单,教程一堆,用的时候去看很快就学会了。
阅读全文
0 0
- SpringBoot使用thymeleaf的简单记录
- SpringBoot + thymeleaf 实现简单的登陆验证
- thymeleaf的简单使用
- springboot thymeleaf简单整合
- SpringBoot使用Thymeleaf所爬过的坑
- SpringBoot使用thymeleaf
- java鬼混笔记:springboot之thymeleaf 1:简单的thymeleaf例子
- springboot(四):thymeleaf使用详解
- SpringBoot使用thymeleaf模板引擎
- springboot使用thymeleaf 解析异常
- Springboot+Thymeleaf配置与使用
- SpringBoot (四) :thymeleaf 使用详解
- springboot(四):thymeleaf使用详解
- springboot(四):thymeleaf使用详解
- springboot中使用thymeleaf模板
- springboot(四):thymeleaf使用详解
- SpringBoot-07引擎模板thymeleaf和freemarker的使用
- Springboot+maven+mysql+thymeleaf 简单框架搭建
- boost 之property_tree操作xml文件
- 用MMDrawerController实现侧滑
- 日历考勤记录
- SpirngMVC异常处理
- android tablelayout嵌套tablayout Fragment嵌套Fragment
- SpringBoot使用thymeleaf的简单记录
- [leetcode]327. Count of Range Sum
- 暑假第22天总结
- 九、 通用工具 ----pair 和Tuple---pair
- Oracle 查询优化的基本准则详解
- 仿今日头条频道管理
- PAT 1023. 组个最小数
- Windows下配置nginx+php(wnmp)
- C++笔记