您的位置:首页技术文章
文章详情页

Springboot使用thymeleaf动态模板实现刷新

【字号: 日期:2023-04-29 14:52:50浏览:4作者:猪猪

当springmvc转向springboot的时候,发现springboot默认支持thymeleaf,对于一直使用jsp的程序员,还是有点不适应。

不过研究了一会发现thymeleaf更加适合前后分离,所以果断抛弃jsp转入thymeleaf,最头疼的就是修改完之后不会自动刷新。

首先要在配置文件application.yml (或 application.properties)

spring thymeleaf: cache: false #重点是这个要设置false不然会无效 prefix: classpath:/thymeleaf/ suffix: .html mode: HTML5 encoding: UTF-8

浏览器也需要设置disabled cache不然也不会有效果,图下图所示

Springboot使用thymeleaf动态模板实现刷新

保存后手动点击Build -> BuildProject,也就是下图的按钮

Springboot使用thymeleaf动态模板实现刷新

这样thymeleaf就会自动更新页面数据。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持好吧啦网。

标签: Spring
相关文章: