【发布时间】:2017-10-26 05:20:34
【问题描述】:
我正在我的 Spring Web 应用程序中启用消息 i18n。为此,我的servlet.xml中有以下代码
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages/message"/>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
添加上述代码后,只要我在浏览器中点击我的应用程序,就会出现以下异常日志:
SEVERE: Servlet.service() for servlet [default] in context with path [/ERP-Web] threw exception [Filter execution threw an exception] with root cause
java.lang.StackOverflowError
at org.springframework.context.support.ReloadableResourceBundleMessageSource.getMergedProperties(ReloadableResourceBundleMessageSource.java:235)
at org.springframework.context.support.ReloadableResourceBundleMessageSource.resolveCodeWithoutArguments(ReloadableResourceBundleMessageSource.java:176)
at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:209)
at org.springframework.context.support.AbstractMessageSource.getMessageFromParent(AbstractMessageSource.java:257)
最后两行重复了 100 次并给了我StackoverflowException。
当我使用ResourceBundleMessageSource 类时,会出现完全相同的异常。
我的春季版是4.3.6.RELEASE。
以下是我的属性文件的内容
action.add.success = New {0} added successfully.
action.add.failure = Some error occurred in adding new {0}. Please try again later or contact administrator.
示例项目位于GitHub
【问题讨论】:
-
添加您的消息属性文件,在我的情况下,无论有无类路径都可以正常工作
-
它加载了属性文件,但是当我从浏览器中点击我的应用程序时,我就出现了异常。
-
很奇怪。您是否有一个迷你项目来重现错误以便可以对其进行调查?
-
呃……会尝试给你一个迷你项目。不过可能需要一两天。为这个延迟表示歉意
-
添加了示例项目@TestoTestini
标签: java spring maven spring-mvc internationalization