Spring ReloadableResourceBundleMessageSource VS ResourceBundleMessageSource

Hey. I am trying to configure message sources in my Spring MVC web application.

I am currently running it with ReloadableResourceBundleMessageSource, but I cannot run it with ResourceBundleMessageSource. I would prefer to use ResourceBundleMessageSource, because I do not need reloading capabilities, and ResourceBundleMessageSource is somewhat more efficient.

in my rootApplicationContext, I defined beans as follows.

<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> 

It works fine ..

But as soon as I switch to

 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="/resources/locale/messages" /> <property name="defaultEncoding" value="UTF-8"/> </bean> 

The application crashes with the exception of:

12: 35: 57,433 ERROR [Org.apache.catalina.core.ContainerBase. [Jboss.web]. [Default is the host]. [/ SpringJAXWS]. [JSP]] (http-localhost-127.0.0.1-8080-1) Servlet.service () for the jsp servlet threw an exception: org.apache.tiles.util.TilesIOException: JSPException including the path '/ jsp / views / layout / top .jsp '. in 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) [Tile-JSP-2.2.2.jar: 2.2.2]

HELP!

All project code is available on GITHUB

https://github.com/localghost8080/JaxWS

Here is a whole stack trace for anyone interested.

https://github.com/localghost8080/JaxWS/blob/master/ResourceBundleException.txt

+6
source share
1 answer

ResourceBundleMessageSource uses a different format for passing base name values

 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="resources.locale.messages" /> <property name="defaultEncoding" value="UTF-8"/> 

0
source

Source: https://habr.com/ru/post/958687/


All Articles