SpringBoot——》Thymeleaf
发布日期:2021-09-14 23:18:19
浏览次数:13
分类:技术文章
本文共 1187 字,大约阅读时间需要 3 分钟。
SpringBoot——》thymeleaf
一、项目依赖配置
org.springframework.boot spring-boot-starter-thymeleaf
二、thymeleaf参数配置
参数对应jar包(版本可变动):spring-boot-autoconfigure-2.1.1.RELEASE.jar
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties
注:在 application.yml
或 application.property
中配置 spring: # 模板引擎 thymeleaf: # Thymeleaf3.0模板:HTML (默认)、XML、TEXT、JAVASCRIPT、CSS、RAW mode: HTML encoding: utf-8 # 禁用缓存:避免改了模板还要重启服务器 cache: false # 资源信息 messages: # 国际化资源文件路径 basename: static/i18n/messages
1、默认模板存放路径
默认值:classpath:/templates/
可修改:spring: thymeleaf: prefix:/templates/
2、默认模板后缀
默认值:.html
可修改:spring: thymeleaf: suffix:.html
3、默认静态资源路径 (4种)
classpath:/META-INF/resources/
classpath:/resources/
classpath:/static/
classpath:/public/
三、示例:Controller和index.html
在src/main/java/com/controller
下新建 WebController.java
import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.GetMapping; @Controllerpublic class WebController { @GetMapping("/index") public String index(){ return "index"; }}
在 classpath:/resources/templates
下新建 index.html
Title 我是小仙
转载地址:https://blog.csdn.net/weixin_43453386/article/details/102782945 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2024年03月30日 10时58分46秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
让Squid 显示本地时间
2021-06-30
linux mysql 命令 大全
2021-06-30
清除Squid缓存的小工具
2021-06-30
Varnish Cache 3.0.0安装
2021-06-30
2011年6月编程语言关注度排行
2021-06-30
Varnish使用小结
2021-06-30
千万级并发HAproxy均衡负载系统介绍
2021-06-30
什么是A记录、MX记录、CNAME记录
2021-06-30
MongoDB简介
2021-06-30
Varnish purges 缓存清除
2021-06-30
Linux下redis安装部署
2021-06-30
水平切分与垂直切分
2021-06-30
MySQL引擎
2021-06-30
MySQL下的NoSQL解决方案HandlerSocket
2021-06-30
Apache服务器下使用 ab 命令进行压力测试
2021-06-30
查看Firefox中的缓存
2021-06-30
http header头设置反向代理不缓存
2021-06-30
配置MySQL主从复制
2021-06-30
CI框架如何删除地址栏的 index.php
2021-06-30
expires与etag控制页面缓存的优先级
2021-06-30