zoukankan      html  css  js  c++  java
  • Spring boot与thymeleaf的集成

        # thymeleaf热部署
        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;
              }


    /** * 模板资源解析器 * @return */ @Bean @ConfigurationProperties(prefix = "spring.thymeleaf") public SpringResourceTemplateResolver templateResolver() { SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); templateResolver.setApplicationContext(this.applicationContext); templateResolver.setCharacterEncoding("UTF-8"); templateResolver.setCacheable(thymeleafCacheEnable); return templateResolver; } /** * Thymeleaf标准方言解释器 */ @Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.setTemplateResolver(templateResolver()); // 支持Spring EL表达式 templateEngine.setEnableSpringELCompiler(true); // 支持SpringSecurity方言 SpringSecurityDialect securityDialect = new SpringSecurityDialect(); templateEngine.addDialect(securityDialect); return templateEngine; } /** * 视图解析器 */ @Bean public ThymeleafViewResolver viewResolver() { ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); viewResolver.setTemplateEngine(templateEngine()); return viewResolver; }

      

  • 相关阅读:
    16位汇编第一讲简介
    COM编程_第一讲_深入COM框架以及实现简单的COM
    COM_第四讲_保存GUID_优化使用代码
    C语言_第二讲_规范以及常用数据类型
    C语言_第一讲_C语言入门
    计算机基础知识_原码反码补码
    计算机基础知识_进制转化
    计算机基础知识_硬件知识
    试题总结2
    试题总结1
  • 原文地址:https://www.cnblogs.com/dibinbin/p/12091961.html
Copyright © 2011-2022 走看看