• 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; }

      

  • 相关阅读:
    js自执行函数的几种不同写法的比较
    chrome浏览器font-size<12px无效解决办法
    清楚浮动的那些事
    css中font-family的中文字体
    雅虎34条军规
    Modernizr的介绍和使用
    手机也能拍大片
    响应式Web设计 – 布局
    JAVA基础-JDBC连接池
    JAVA基础-JDBC使用
  • 原文地址:https://www.cnblogs.com/dibinbin/p/12091961.html
Copyright © 2020-2023  润新知