zoukankan      html  css  js  c++  java
  • sringboot中使用thymeleaf动态模板刷新

      当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不然也不会有效果,图下图所示

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

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

    希望以上对大家有帮助!

  • 相关阅读:
    template(2.2)
    Filter过滤链条
    The 3n + 1 problem
    Struts2.3+Spring4.0
    康托展开
    templates(2.1)
    templates(1.2)
    templates(1.1)
    我和你
    Android 的上下文菜单: Context Menu
  • 原文地址:https://www.cnblogs.com/zrl66/p/11423749.html
Copyright © 2011-2022 走看看