spring boot2.3.0集成 thymelaf
配置pom
如果是2.x的直接配置一个starter即可
<!-- ThymeLeaf 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
如果是1.x的 还需要配置一些参数
<!-- 布局功能的支持程序 thymeleaf3主程序 layout2以上版本 -->
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
resoruces下面建立 templates文件夹
把html文件放在templates里面,以.html结尾,可以在html里面加入命名声明
<html lang="en" xmlns:th="http://www.thymeleaf.org">
编写controller类,用@Controller 不要用@RestController!如果前后端分离不是很彻底的项目,建议在controllr包 分为API和view包。分别放纯接口返回一个放模板访问的
@Controller //注意 不要用 RestController
public class Say {
@RequestMapping("hi")
public String hi() {
return "/list"; //需要加入”/“, 反而RequestMapping里面如果是直接访问反而不需要"/”
}
}配置application.yml文件(非强制)
spring:
thymeleaf:
mode: HTML
encoding: UTF-8
servlet:
content-type: text/html
prefix: classpath:/templates
suffix: .html
cache: false
public class Say {
@RequestMapping("hi")
public String hi() {
return "/list"; //这里需要加入”/“, 反而RequestMapping里面如果是直接访问反而不需要"/”
}
}
Loading definitions...
spring boot2.3.0集成 thymelaf的更多相关文章
- spring boot 2.0 集成 shiro 和 pac4j cas单点登录
新开的项目,果断使用 spring boot 最新版本 2.0.3 ,免得后期升级坑太多,前期把雷先排了. 由于对 shiro 比较熟,故使用 shiro 来做权限控制.同时已经存在了 cas ...
- spring boot2.x中集成H2数据库
H2数据库介绍 查看 在spring boot中集成 1.添加依赖 <dependency> <groupId>org.springframework.boot</gr ...
- Spring Boot 2.0 集成 Druid 数据源
一.Maven项目依赖 <!-- 开发者工具(热部署 修改classpath下的文件springboot自动重启) --> <dependency> <groupId&g ...
- spring boot2 运行环境
1.springboot个版本系统需求 spring boot maven jdk 内置tomcat 内置jetty servlet 2.0.x 3.2+ 8或9 8.5(3.1) 9.4(3.1) ...
- 【spring cloud】spring cloud2.X spring boot2.0.4调用feign配置Hystrix Dashboard 和 集成Turbine 【解决:Hystrix仪表盘Unable to connect to Command Metric Stream】【解决:Hystrix仪表盘Loading...】
环境: <java.version>1.8</java.version><spring-boot.version>2.0.4.RELEASE</spring- ...
- Spring Boot2.0使用Spring Security
一.Spring Secutity简介 Spring 是一个非常流行和成功的 Java 应用开发框架.Spring Security 基于 Spring 框架,提供了一套 Web 应用安全性 ...
- spring boot 2.0(一)权威发布spring boot2.0
Spring Boot2.0.0.RELEASE正式发布,在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误,然后Spring ...
- Spring Boot2.0之整合事物管理
首先Spring 事务分类 1.声明事务 原理:基于编程事务的 2.编程事务 指定范围 扫包去解决 3.事务原理:AOP技术 通过环绕通知进行了拦截 使用Spring 事务注意事项: 不要tr ...
- 基于spring boot2.0+spring security +oauth2.0+ jwt微服务架构
github地址:https://github.com/hankuikuide/microservice-spring-security-oauth2 项目介绍 该项目是一个演示项目,主要演示了,基于 ...
- SpringBoot之整合Quartz调度框架-基于Spring Boot2.0.2版本
1.项目基础 项目是基于Spring Boot2.x版本的 2.添加依赖 <!-- quartz依赖 --> <dependency> <groupId>org.s ...
随机推荐
- 2022强网拟态 WHOYOUARE
2022强网拟态 WHOYOUARE 先说一下这个思路 由于禁用了__proto__所以我们可以通过constructor.prototype来绕过 之前一直不明白为什么是这样绕过的后来仔细研究了一下 ...
- vue 项目中引入图片使用相对路径,图片不显示的问题
在 vue 项目中引入图片,路径为相对路径时,会显示 src="[object Module]" 采用 import 方式引入图片,再设置到 src 中 会正常显示 file-lo ...
- thinkphp6+composer+无集成工具 配置php项目环境
安装composer 下载地址:https://getcomposer.org/Composer-Setup.exe 安装步骤 点击finish完成即可. 打开cmd输入composer查看是否安装成 ...
- 常见的abd命令
https://blog.csdn.net/qq_34512207/article/details/125283285
- laravel request lifecycle
1, index.php2, 生成service container3, service provider register/booted4, dispatch routing5, middlew ...
- lineHeight 和fontSize的区别
参考资料:https://blog.csdn.net/WuLex/article/details/94667136 暂时记录,待测试确认. lineHeight包含了行间距,而fontSize只是字体 ...
- 像MIUI一样做Zabbix二次开发(2)——Zabbix与商业及开源产品的比较分析
Zabbix的特点 Zabbix是一个基于WEB界面的提供分布式系统监控的开源解决方案,通过浏览器监视,做到告警分级处理.网络访问安全可控,该开源平台在全球有广泛的用户基础,他的特点: 开放性:源代码 ...
- 实时搜索引擎Elasticsearch
Elasticsearch(简称ES)是一个基于Apache Lucene(TM)的开源搜索引擎,无论在开源还是专有领域,Lucene可以被认为是迄今为止最先进.性能最好的.功能最全的搜索引擎库. E ...
- SqlServer中 Partition By 的使用( 对多行数据分组后排序取每个产品的第一行数据)
1:数据库表结构: (产品图片表) select * from product_imgs 2:应用场景: 可见表中每一个产品(pro_id)可能对应多个图片(img),我想要按照添加时间的先后顺序,获 ...
- Docker--搭建 Gitlab 容器并上传本地项目代码
本文参考:https://www.cnblogs.com/poloyy/p/13969756.html 搭建 Gitlab 容器 搜索 gitlab 镜像 docker search gitlab 创 ...