我一直在使用 Java/Spring 使用 #springMessage()
标签和 message.properties
文件开发一个国际网站。查看我最近的问题:In Java/Spring, how to gracefully handle missing translation values?
我希望能够编辑(覆盖)messages.properties 文件并能够立即在我的浏览器中看到新的翻译(无需重新启动 Tomcat)。
我认为 http://commons.apache.org/proper/commons-configuration/userguide/howto_filebased.html#Automatic_Reloading将是我需要的,但我不确定如何编辑我的 webmvc-config.xml 以使用它。
最佳答案
想通了。它在我编辑 webmvc-config.xml 后起作用:
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename">
<value>${content.path.config}/WEB-INF/messages</value>
</property>
<property name="defaultEncoding" value="UTF-8" />
<property name="cacheSeconds" value="2"/>
</bean>
(我只需要添加 cacheSeconds 属性。)
关于java - 如何在 Java/Spring 中自动重新加载 messages.properties 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18152819/