Spring Boot thymeleaf模版支持,css,js等静态文件添加
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等静态文件添加的更多相关文章
- Spring boot+Thymeleaf+easyui集成:js创建组件页面报错
开发工具:Ideal 使用场景:Demo 前提: 环境:Spring boot +Thymeleaf+easyui 引入thymeleaf模板引擎 <html lang=" ...
- spring boot + Thymeleaf开发web项目
"Spring boot非常适合Web应用程序开发.您可以轻松创建自包含的HTTP应用.web服务器采用嵌入式Tomcat,或者Jetty等.大多数情况下Web应用程序将使用 spring- ...
- Spring Boot Thymeleaf 实现国际化
开发传统Java WEB工程时,我们可以使用JSP页面模板语言,但是在SpringBoot中已经不推荐使用了.SpringBoot支持如下页面模板语言 Thymeleaf FreeMarker Vel ...
- Springboot 系列(十七)迅速使用 Spring Boot Admin 监控你的 Spring Boot 程序,支持异常邮件通知
1. Spring Boot Admin 是什么 Spring Boot Admin 是由 codecentric 组织开发的开源项目,使用 Spring Boot Admin 可以管理和监控你的 S ...
- spring boot + thymeleaf 3 国际化
在给spring boot 1.5.6 + thymeleaf 3进行国际化时,踩了一个坑(其实不止一个). 现象: 看到了吧, 就是取值的key, 后面被加了_en_US 或 _zh_CN, 以及前 ...
- spring boot: thymeleaf模板引擎使用
spring boot: thymeleaf模板引擎使用 在pom.xml加入thymeleaf模板依赖 <!-- 添加thymeleaf的依赖 --> <dependency> ...
- Spring Boot Thymeleaf 模板引擎的使用
Spring Boot 中可以支持很多模板引擎,Thymeleaf 是 Spring Boot 官方推荐使用的模板引擎,虽然在社区 Thymeleaf 的性能被许多人所吐糟,但这仍然不影响大量的开发人 ...
- Spring Boot 之FilterRegistrationBean --支持web Filter 排序的使用(转)
Spring Boot 之FilterRegistrationBean --支持web Filter 排序的使用Spring 提供了FilterRegistrationBean类,此类提供setOr ...
- spring boot + thymeleaf 乱码问题
spring boot + thymeleaf 乱码问题 hellotrms 发布于 2017/01/17 15:27 阅读 1K+ 收藏 0 答案 1 开发四年只会写业务代码,分布式高并发都不会还做 ...
随机推荐
- vue环境的搭建与第一个demo
参考两个博客 1 2 git.npm和淘宝镜像的安装过程过程省略了,直接开始webpack + vue-cli + 创建demo 首先,在磁盘创建一个文件夹,命名为vue-projects,里面再建一 ...
- js DOM操作 容易犯的错误
这样一段html片段 <select class="form-control" id="course_chapter" onchange="fi ...
- java9最新发布
链接:http://pan.baidu.com/s/1slbRFa9 密码:hcdj 给大家分享可以去下载 已接受的特性 1. Jigsaw 项目:模块化JDK源码 Jigsaw项目即JEP201是为 ...
- Django url (路由)
1.路由的基本使用 #url 是个函数,有四个参数,第一个参数要传正则表达式,第二个参数传函数内存地址,第三个传默认参数,第四个传路由别名 url(r'^yaopipqideneirong/art ...
- python版接口自动化测试框架源码完整版(requests + unittest)
python版接口自动化测试框架:https://gitee.com/UncleYong/my_rf [框架目录结构介绍] bin: 可执行文件,程序入口 conf: 配置文件 core: 核心文件 ...
- git的git bash使用
一.git配置 在你使用git之前,需要先进行配置,即要报名号,否则不能提交代码 $ git config --global user.name # 你是谁 $ git config --global ...
- 金融量化分析【day113】:聚宽自带策略
一.策略代码 # 导入函数库 from jqdata import * # 初始化函数,设定基准等等 def initialize(context): # 设定沪深300作为基准 set_benchm ...
- wxpython多线程间通信
#!bin/bash/python # -*- coding=utf-8 -*- import time import wx from threading import Thread from wx. ...
- 第十四节: EF的三种模式(四) 之 原生正宗的 CodeFirst模式的默认约定
一. 简介 1. 正宗的CodeFirst模式是不含有edmx模型,需要手动创建实体.创建EF上下文,然后生成通过代码来自动映射生成数据库. 2. 旨在:忘记SQL.忘记数据库. 3. 三类配置:On ...
- c#管理文件系统
using System; using System.Collections.Generic; using System.IO; using static System.Console; /*Syst ...