spring boot Thymeleaf 页面包含和页面热部署
2018-02-27 11:03
351 查看
1、Thymeleaf 页面包含其它页面
在开发web应用的过程中,经常需要引用到其它的页面。举例来说,我有两个页面一个页面叫index.html,另外一个页面叫session.html。现在index.html需要将session.html引入。在spring boot项目的templates文件夹下面新建这两个文件。session.html中的代码如下:
<div th:fragment="copy" xmlns:th="http://www.w3.org/1999/xhtml"> © 2014 The Good Thymes Virtual Grocery </div>
index.html的代码如下
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"/> <title>主页面</title> </head> <body> <h4>5说点什么吧!</h4> <div th:replace="session::copy"></div> </body> </html>
使用标签 th:replace替换html中的片段,其中::前面的session是文件名称,copy是session.html中的div的id
2、Thymeleaf 热部署
在开发的过程中,页面经常修改而希望不需要重新启动,使用Thymeleaf模板需要在application.properties文件中,加上一行:spring.thymeleaf.cache=false
之后修改完html页面之后,在IDEA中按下ctrl + shift + F9 键重新编译,或者在编辑文件中,按右键选择重新编译文件。再刷新浏览器即可更新页面。
相关文章推荐
- springboot开发日志(4): thymeleaf模板 自定义404和500页面
- Ideal+spring boot+thymeleaf 的热部署问题处理
- eclipse中使用spring boot 入门开发(包含:与jsp页面和数据库交互,cmd打包运行war包)
- 微服务,微架构[十一]springboot模板页面thymeleaf
- SpringBoot+thymeleaf项目页面的一些问题
- 访问不存在的Thymeleaf 资源时使页面转向 404,而不是500 (Spring Boot)
- SpringBoot thymeleaf模板页面没提示,SpringBoot thymeleaf模板插件安装
- thymeleaf+spring boot 页面hashmap取值
- 在部署到Servlet容器之前,如何生成包含SpringBoot的War文件
- spring boot系列 - thymeleaf跳转页面
- spring boot+spring security+thymeleaf在页面上判断用户是否登录
- springboot 常用两种图形形式(thymeleaf模板,jsp页面)
- spring boot部署中一个斜杠引发的血案--org.thymeleaf.exceptions.TemplateInputException
- [spring boot] 用 thymeleaf模板开发html页面
- spring boot使用thymeleaf跳转页面实例代码
- springboot 使用 thymeleaf 模板引擎。在页面写隐藏域接收后台的值。在页面进行对话框提示。
- springboot学习(4)springboot使用thymeleaf完成数据的页面展示
- [spring boot][thymeleaf]spring boot 1.5+ 页面无法找到
- springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用
- springboot如何使用thymeleaf模板访问html页面