java.lang.Object | ||||
↳ | org.springframework.context.support.ApplicationObjectSupport | |||
↳ | org.springframework.web.context.support.WebApplicationObjectSupport | |||
↳ | org.springframework.web.servlet.view.AbstractCachingViewResolver | |||
↳ | org.springframework.web.servlet.view.ResourceBundleViewResolver |
ViewResolver
implementation
that uses bean definitions in a ResourceBundle, specified by
the bundle basename.
The bundle is typically defined in a properties file, located in the class path. The default bundle basename is "views".
This ViewResolver
supports localized view definitions,
using the default support of java.util.PropertyResourceBundle.
For example, the basename "views" will be resolved as class path resources
"views_de_AT.properties", "views_de.properties", "views.properties" -
for a given Locale "de_AT".
Note: this ViewResolver
implements the Ordered
interface to allow for flexible participation in ViewResolver
chaining. For example, some special views could be defined via this
ViewResolver
(giving it 0 as "order" value), while all
remaining views could be resolved by a UrlBasedViewResolver
.
getBundle(String)
UrlBasedViewResolver
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_BASENAME | The default basename if no other basename is supplied. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.core.Ordered
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Eagerly initialize Locales if necessary.
| |||||||||||
Close the bundle View factories on context shutdown.
| |||||||||||
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
| |||||||||||
Set a single basename, following
ResourceBundle conventions. | |||||||||||
Set an array of basenames, each following
ResourceBundle
conventions. | |||||||||||
Set the
ClassLoader to load resource bundles with. | |||||||||||
Set the default parent for views defined in the
ResourceBundle . | |||||||||||
Specify Locales to initialize eagerly, rather than lazily when actually accessed.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Obtain the resource bundle for the given basename and
Locale . | |||||||||||
Return the
ClassLoader to load resource bundles with. | |||||||||||
Subclasses must implement this method, building a View object
for the specified view.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.view.AbstractCachingViewResolver
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.DisposableBean
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.core.Ordered
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.ViewResolver
|
The default basename if no other basename is supplied.
Return the order value of this object, with a higher value meaning greater in terms of sorting.
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
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.
Set an array of basenames, each following ResourceBundle
conventions. The default is a single basename "views".
ResourceBundle
supports different suffixes. For example,
a base name of "views" might map to ResourceBundle
files
"views", "views_en_au" and "views_de".
The associated resource bundles will be checked sequentially when resolving a message code. Note that message definitions in a previous resource bundle will override ones in a later bundle, due to the sequential lookup.
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.
Set the ClassLoader
to load resource bundles with.
Default is the thread context ClassLoader
.
Set the default parent for views defined in the ResourceBundle
.
This avoids repeated "yyy1.(parent)=xxx", "yyy2.(parent)=xxx" definitions in the bundle, especially if all defined views share the same parent.
The parent will typically define the view class and common attributes. Concrete views might simply consist of an URL definition then: a la "yyy1.url=/my.jsp", "yyy2.url=/your.jsp".
View definitions that define their own parent or carry their own class can still override this. Strictly speaking, the rule that a default parent setting does not apply to a bean definition that carries a class is there for backwards compatiblity reasons. It still matches the typical use case.
Specify Locales to initialize eagerly, rather than lazily when actually accessed.
Allows for pre-initialization of common Locales, eagerly checking the view configuration for those Locales.
Obtain the resource bundle for the given basename and Locale
.
basename | the basename to look for |
---|---|
locale | the Locale to look for |
ResourceBundle
MissingResourceException | if no matching bundle could be found |
---|
Return the ClassLoader
to load resource bundles with.
Default is the specified bundle ClassLoader
,
usually the thread context ClassLoader
.
Initialize the View BeanFactory
from the ResourceBundle
,
for the given locale
.
Synchronized because of access by parallel threads.
locale | the target Locale |
---|
BeansException | in case of initialization errors |
---|
Subclasses must implement this method, building a View object for the specified view. The returned View objects will be cached by this ViewResolver base class.
Subclasses are not forced to support internationalization: A subclass that does not may simply ignore the locale parameter.
viewName | the name of the view to retrieve |
---|---|
locale | the Locale to retrieve the view for |
null
if not found
(optional, to allow for ViewResolver chaining)Exception |
---|