Is there a way to set a specific location where the ResourceBundleViewResolver
should look for the view.properties
files?
By specific location I mean somewhere not inside the classpath 开发者_开发知识库but anywhere in the file system / network resource.
Thanks in advance.
It doesn't have to be in WEB-INF/classes
, it just has to be somewhere on the classpath, and WEB-INF/classes
is usually the most convenient place.
If you want to put it somewhere else, then you're free to do so, as long as it's in the "root" on the classpath, e.g. inside a JAR under WEB-INF/lib
.
Furthermore, it doesn't have to be called views.properties
, it can be anything you like. Read the javadoc for ResourceBundleViewResolver.setBaseName()
:
Set a single basename, following ResourceBundle conventions. The default is "views".
ResourceBundle supports different suffixes. For example, a base name of "views" might map to ResourceBundle files "views", "views_en_au" and "views_de".
Note that ResourceBundle names are effectively classpath locations: As a consequence, the JDK's standard ResourceBundle treats dots as package separators. This means that "test.theme" is effectively equivalent to "test/theme", just like it is for programmatic java.util.ResourceBundle usage.
So it can be anywhere in the classpath you like. ResourceBundleViewResolver
is a lot more flexible than you're giving it credit for - it pays to read the documentation.
精彩评论