您好我正在尝试在Spring MVC Web应用程序中配置消息源。
我目前使用ReloadableResourceBundleMessageSource运行它,但我无法使用ResourceBundleMessageSource运行它。我宁愿使用ResourceBundleMessageSource,因为我不需要Reload功能,而ResourceBundleMessageSource的效率稍高。
在我的rootApplicationContext中,我已经将bean定义如下。
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/resources/locale/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
这很有效......
但是一旦我改为
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="/resources/locale/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
应用程序中断了例外:
12:35:57,433错误 [org.apache.catalina.core.ContainerBase [jboss.web] [缺省主机]。[/ SpringJAXWS]。[JSP]] (http-localhost-127.0.0.1-8080-1)servlet jsp的Servlet.service() 抛出异常:org.apache.tiles.util.TilesIOException:JSPException 包括路径'/jsp/views/layout/top.jsp'。在 org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:241) [tiles-servlet-2.2.2.jar:2.2.2] at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:105) [瓦片-JSP-2.2.2.jar:2.2.2]
帮助!
https://github.com/localghost8080/JaxWS
https://github.com/localghost8080/JaxWS/blob/master/ResourceBundleException.txt
答案 0 :(得分:0)
ResourceBundleMessageSource使用不同的格式传递basename值
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="resources.locale.messages" />
<property name="defaultEncoding" value="UTF-8"/>