1. # thymeleaf热部署
  2. spring.thymeleaf.cache=false

@Value("${spring.thymeleaf.cache}")
          private boolean thymeleafCacheEnable = true;

private ApplicationContext applicationContext;

@Override
         public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
                     this.applicationContext = applicationContext;
          }

  1. /**
  2. * 模板资源解析器
  3. * @return
  4. */
  5. @Bean
  6. @ConfigurationProperties(prefix = "spring.thymeleaf")
  7. public SpringResourceTemplateResolver templateResolver() {
  8. SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
  9. templateResolver.setApplicationContext(this.applicationContext);
  10. templateResolver.setCharacterEncoding("UTF-8");
  11. templateResolver.setCacheable(thymeleafCacheEnable);
  12. return templateResolver;
  13. }
  14.  
  15. /**
  16. * Thymeleaf标准方言解释器
  17. */
  18. @Bean
  19. public SpringTemplateEngine templateEngine() {
  20. SpringTemplateEngine templateEngine = new SpringTemplateEngine();
  21. templateEngine.setTemplateResolver(templateResolver());
  22. // 支持Spring EL表达式
  23. templateEngine.setEnableSpringELCompiler(true);
  24.  
  25. // 支持SpringSecurity方言
  26. SpringSecurityDialect securityDialect = new SpringSecurityDialect();
  27. templateEngine.addDialect(securityDialect);
  28. return templateEngine;
  29. }
  30.  
  31. /**
  32. * 视图解析器
  33. */
  34. @Bean
  35. public ThymeleafViewResolver viewResolver() {
  36. ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
  37. viewResolver.setTemplateEngine(templateEngine());
  38. return viewResolver;
  39. }

  

Spring boot与thymeleaf的集成的更多相关文章

  1. Spring Boot整合 Thymeleaf 模板引擎

    什么是Thymeleaf Thymeleaf是一款用于渲染XML.XHTML.HTML5内容的模板引擎.类似Velocity,FreeMaker模板引擎,它也可以轻易的与Spring MVC等Web框 ...

  2. Spring Boot整合Thymeleaf模板引擎

    什么是Thymeleaf Thymeleaf是一款用于渲染XML.XHTML.HTML5内容的模板引擎.类似Velocity,FreeMaker模板引擎,它也可以轻易的与Spring MVC等Web框 ...

  3. Spring Boot微服务如何集成fescar解决分布式事务问题?

    什么是fescar? 关于fescar的详细介绍,请参阅fescar wiki. 传统的2PC提交协议,会持有一个全局性的锁,所有局部事务预提交成功后一起提交,或有一个局部事务预提交失败后一起回滚,最 ...

  4. Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例

    Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例 一.快速上手 1,配置文件 (1)pom包配置 pom包里面添加jpa和thymeleaf的相关包引用 ...

  5. spring boot 与 thymeleaf (2): 常用表达式

    在asp.net mvc 中, 有一个视图解析器, 可以支持Razor语法. 使用起来, 是非常的方便, 并且, 写在前台页面的后台方法, 是可调试的. 但是在java中, 目前我还没有接触到, 像. ...

  6. 一个小demo熟悉Spring Boot 和 thymeleaf 的基本使用

    目录 介绍 零.项目素材 一. 创建 Spring Boot 项目 二.定制首页 1.修改 pom.xml 2.引入相应的本地 css.js 文件 3.编辑 login.html 4.处理对 logi ...

  7. Spring Boot2 系列教程(九)Spring Boot 整合 Thymeleaf

    虽然现在慢慢在流行前后端分离开发,但是据松哥所了解到的,还是有一些公司在做前后端不分的开发,而在前后端不分的开发中,我们就会需要后端页面模板(实际上,即使前后端分离,也会在一些场景下需要使用页面模板, ...

  8. Spring Boot 2 + Thymeleaf:表单字段绑定、表单提交处理

    Spring Boot中Thymeleaf对表单处理的一些用法:(1)使用th:field属性:进行表单字段绑定(2)使用ids对象:一般用于lable配合radio或checkbox使用(3)表单提 ...

  9. Spring Boot 2.0 快速集成整合消息中间件 Kafka

    欢迎关注个人微信公众号: 小哈学Java, 每日推送 Java 领域干货文章,关注即免费无套路附送 100G 海量学习.面试资源哟!! 个人网站: https://www.exception.site ...

随机推荐

  1. Spring---基础配置

    1.@Scope 1.1.描述了Spring容器如何新建Bean的实例: 1.2.@Scope(value="") value值有: 1.2.1.singleton 一个Sprin ...

  2. Session过期,如何跳出iframe框架页的问题

    跳出框架页,实际上是更改父页面地址.那么更改父页面地址很简单即: window.parent.location='/Login/loginindex'; 这里说session过期,那么浏览器端的任何请 ...

  3. 【Eureka】实现原理

    Eureka Client 拉取Eureka Server中的全量注册表 注册自身实例InstanceInfo至Eureka Server 初始化定时任务 心跳(续约)任务 拉取增量注册表更新本地注册 ...

  4. spring-boot整合Mybatis案例

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 3.2.5 2.Maven Plugin管理 <?xml version="1.0&q ...

  5. sql 2008常用语法语句收集

    EXEC sp_dropuser 'test' : 从当前数据库删除用户 test EXEC sp_droplogin 'test' : 从 SQL Server 中删除登录 test select ...

  6. SQL server 2008 数据库优化常用脚本

    --查询某个数据库的连接数 select count(*) from Master.dbo.SysProcesses where dbid=db_id() --前名其他等待类型 * from sys. ...

  7. php max()函数 语法

    php max()函数 语法 作用:从所有参数中找到最大数 语法:max(X,Y,Z) 或者max(array(X,Y,Z)) 参数:max函数中参数至少一个,可以多个参数,也可以是数组. 说明:如果 ...

  8. [ZJOI2019]开关

    以下的方案数默认是带权方案数.设\(P=\sum_{i=1}^np_i\). 设\(F(x)\)为按\(i\)次开关后到达终止态的方案数的EGF,\(f\)为\(F\)的OGF,显然\(F(x)=\p ...

  9. EF框架实增删改查

    数据库链接配置: <connectionStrings> <add name="XxzxWorkEntities" connectionString=" ...

  10. HTML 3-列表、表单、语义化

    有序列表.无序列表.自定义列表在语义上的区别 1.有序列表ol>li:列表有顺序编号(默认列表前加1.,2.,3.,...编号),适用于有逻辑顺序的排列项目,而且次序不能乱.2.无序列表ul&g ...