PDA

View Full Version : Location of View Properties (ResourceBundleViewResolver)


umark
Jun 5th, 2006, 11:40 PM
I am using Spring 1.2.8 with Tomcat 4.1.13.

I have configured the ResourceBundleViewResolver as follows:

<bean id="viewResolver"
class="org.springframework.web.servlet.view.ResourceBundl eViewResolver">
<property name="basename">
<value>views</value>
</property>
</bean>

and have placed views.properties and views_en_US.properties in
umark/WEB-INF:
$ cd umark/WEB-INF
$ ls views*
views.properties and views_en_US.properties
$

However, ResourceBundleViewResolver fails to find
either views.properties or views_en_US.properties and issues
the MissingResourceException (shown below).

My question is: in a webapp where does the view resolver look for
the localized vie wproperties?

Regards,

Umark

java.util.MissingResourceException: Can't find bundle for base name views, locale en_US
at java.util.ResourceBundle.throwMissingResourceExcep tion(ResourceBundle.java:804)
at java.util.ResourceBundle.getBundleImpl(ResourceBun dle.java:694)
at java.util.ResourceBundle.getBundle(ResourceBundle. java:661)
at org.springframework.web.servlet.view.ResourceBundl eViewResolver.getBundle(ResourceB
undleViewResolver.java:222)

avspring
Jun 6th, 2006, 01:10 AM
Please place the views properties file in /WEB-INF/classes dir.
it will work.
thanks

umark
Jun 7th, 2006, 02:46 PM
Please place the views properties file in /WEB-INF/classes dir.
it will work.
thanks

Thank you! That worked. The resources ned to be placed in WEB-INF/classes
because its the ClassLoader that is loading it and it hence
looks for it at the top of the classpath?

I 'd like to hide te views.properties from users. Ideally, post
development, this should be bundled in a jarfile. In order to have
the Classloader find it in my jarfile, I would have to
trivially extend ResourceBundleViewResolve (to MyResourceBundleViewResolver), package it in my own jarfile
and place the views properties in the jarfile?

Is there a better way?

Thanks again for your assistance.

Umark