Thymeleaf引入

Thymeleaf是一个Java模板引擎开发库,可以处理和生成HTML、XML、JavaScript、CSS和文本,在Web和非Web环境下都可以正常工作。

1.添加依赖包

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2.添加配置项目

# 模板配置
# 这个开发配置为false,避免改了模板还要重启服务器
spring.thymeleaf.cache=false
# 这个是配置模板路径的,默认就是templates,可不用配置
spring.thymeleaf.prefix=classpath:/templates/
# 这个可以不配置,检查模板位置
spring.thymeleaf.check-template-location=true
# 下面3个不做解释了,可以不配置
spring.thymeleaf.suffix=.html
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html # 模板的模式
spring.thymeleaf.mode=HTML5

3.添加

 @RequestMapping("/list")
public String listUser(Model model) {
List<User> userList = new ArrayList<User>();
for (int i = 0; i <10; i++) {
userList.add(new User(i,"张三"+i,20+i,"中国广州"));
} model.addAttribute("users", userList);
return "/user/list";
}

Spring Boot thymeleaf模版支持,css,js等静态文件添加的更多相关文章

  1. Spring boot+Thymeleaf+easyui集成:js创建组件页面报错

    开发工具:Ideal 使用场景:Demo 前提:       环境:Spring boot +Thymeleaf+easyui 引入thymeleaf模板引擎 <html lang=" ...

  2. spring boot + Thymeleaf开发web项目

    "Spring boot非常适合Web应用程序开发.您可以轻松创建自包含的HTTP应用.web服务器采用嵌入式Tomcat,或者Jetty等.大多数情况下Web应用程序将使用 spring- ...

  3. Spring Boot Thymeleaf 实现国际化

    开发传统Java WEB工程时,我们可以使用JSP页面模板语言,但是在SpringBoot中已经不推荐使用了.SpringBoot支持如下页面模板语言 Thymeleaf FreeMarker Vel ...

  4. Springboot 系列(十七)迅速使用 Spring Boot Admin 监控你的 Spring Boot 程序,支持异常邮件通知

    1. Spring Boot Admin 是什么 Spring Boot Admin 是由 codecentric 组织开发的开源项目,使用 Spring Boot Admin 可以管理和监控你的 S ...

  5. spring boot + thymeleaf 3 国际化

    在给spring boot 1.5.6 + thymeleaf 3进行国际化时,踩了一个坑(其实不止一个). 现象: 看到了吧, 就是取值的key, 后面被加了_en_US 或 _zh_CN, 以及前 ...

  6. spring boot: thymeleaf模板引擎使用

    spring boot: thymeleaf模板引擎使用 在pom.xml加入thymeleaf模板依赖 <!-- 添加thymeleaf的依赖 --> <dependency> ...

  7. Spring Boot Thymeleaf 模板引擎的使用

    Spring Boot 中可以支持很多模板引擎,Thymeleaf 是 Spring Boot 官方推荐使用的模板引擎,虽然在社区 Thymeleaf 的性能被许多人所吐糟,但这仍然不影响大量的开发人 ...

  8. Spring Boot 之FilterRegistrationBean --支持web Filter 排序的使用(转)

    Spring Boot 之FilterRegistrationBean  --支持web Filter 排序的使用Spring 提供了FilterRegistrationBean类,此类提供setOr ...

  9. spring boot + thymeleaf 乱码问题

    spring boot + thymeleaf 乱码问题 hellotrms 发布于 2017/01/17 15:27 阅读 1K+ 收藏 0 答案 1 开发四年只会写业务代码,分布式高并发都不会还做 ...

随机推荐

  1. Fixing “Did you mean to run dotnet SDK commands?” error when running dotnet –version

    I recently installed the dotnet 1.11.0 Windows Server Hosting package which apparently installs the ...

  2. git 学习(1) ----- git 本地仓库操作

    最近在项目中使用git了,在实战中才知道,以前学习的git 知识只是皮毛,需要重新系统的学一下,读了一本叫  Learn Git in a Month of Lunches 的书籍,这本书通俗易懂,使 ...

  3. js 实现论坛评论模块原理

    <body>   <table id="tb" border="1">   <tbody id="tbd"&g ...

  4. JarvisOJ Misc webshell分析

    分析压缩包中的数据包文件并获取flag.flag为32位大写md5. 神仙们还是强啊,webshell主要看http流,再过滤只剩下post请求 可以使用 http.request.method == ...

  5. Manacher算法详解

    问题 什么是回文串,如果一个字符串正着度读和反着读是一样的,这个字符串就被称为回文串. such as noon level aaa bbb 既然有了回文,那就要有关于回文的问题,于是就有了-- 最长 ...

  6. Kubernetes 中的渐进式交付:蓝绿部署和金丝雀部署

    渐进式交付是持续交付的下一步, 它将新版本部署到用户的一个子集,并在将其滚动到全部用户之前对其正确性和性能进行评估, 如果不匹配某些关键指标,则进行回滚. 这里有一些有趣的项目,使得渐进式交付在 Ku ...

  7. 【JVM】JVM垃圾收集器、垃圾收集算法、无用对象

    Java 常见的垃圾收集器有哪些 实际上,垃圾收集器(GC,Garbage Collector)是和具体 JVM 实现紧密相关的,不同厂商(IBM.Oracle),不同版本的JVM,提供的选择也不同. ...

  8. U66785 行列式求值

    二更:把更多的行列式有关内容加了进来(%%%%%Jelly Goat奆佬) 题目描述 给你一个N(n≤10n\leq 10n≤10)阶行列式,请计算出它的值 输入输出格式 输入格式: 第一行有一个整数 ...

  9. qml : qml控件自适应;

    import QtQuick 2.4 Item { property var targetItem: parent property bool fixedAspectRatio: true // El ...

  10. TPS、并发用户数、吞吐量关系

    TPS.并发用户数.吞吐量关系 摘要 主要描述了在性能测试中,关于TPS.并发用户数.吞吐量之间的关系和一些计算方法. loadrunner TPS 目录[-] 一.系统吞度量要素: 二.系统吞吐量评 ...