带有 Thymeleaf 的 Spring MVC.更新静态数据 [英] Spring MVC with Thymeleaf. Update static data

查看:31
本文介绍了带有 Thymeleaf 的 Spring MVC.更新静态数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Spring MVC 与 Thymeleaf 和 Tomcat 一起使用,我希望能够在不重新部署的情况下更新静态数据(html 页面).在我的应用程序中,html 是由 Spring 控制器映射的.即使 JRebel 也无济于事.它很好地更新了 Java 类,但对视图没有任何作用.我应该怎么做才能解决这个问题?也许对于 html,我需要一些像 Jasper for JSP 这样的侦听器机制,或者我应该为 Spring 控制器禁用一些缓存?..

I'm using Spring MVC with Thymeleaf and Tomcat and I want to be able update static data (html pages) without redeploy. In my application html is mapping by Spring controller. Even JRebel doesn't helps. It updates java classes great, but does nothing with view. What should I do to solve this issue? Maybe for html I need some listener mechanism like Jasper for JSP, or maybe I should disable some cache for Spring controller?..

推荐答案

这实际上是 Thymeleaf 问题.我只需要禁用 templateResolver 的缓存,默认情况下它是打开的.

This actually was Thymeleaf issue. I just had to disable caching for templateResolver, which is ON by default.

<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
    <property name="prefix" value="/" /> 
    <property name="suffix" value=".html" /> 
    <property name="templateMode" value="HTML5" /> 
    <property name="cacheable" value="false"/>
</bean>

这篇关于带有 Thymeleaf 的 Spring MVC.更新静态数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆