Deprecated
as of 5.3, in favor of Spring's common view resolver variants and/or custom resolver implementations
org.springframework.web.servlet.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 classpath. The default bundle basename is "views".
This ViewResolver supports localized view definitions, using the
default support of java.. 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
in order 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.
java.util.ResourceBundle#getBundle , java.util.PropertyResourceBundle , UrlBasedViewResolver, BeanNameViewResolver
| Modifier and Type | Field and Description |
|---|---|
| private String[] | |
| private final Map | |
| private ClassLoader | |
| public static final String | DEFAULT_BASENAME
The default basename if no other basename is supplied. |
| private String | |
| private final Map | |
| private Locale[] | |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. Eagerly initialize Locales if necessary. |
| public void | destroy()
Implements org. Close the bundle View factories on context shutdown. |
| protected ResourceBundle | |
| protected ClassLoader | |
| public int | |
| protected synchronized BeanFactory | Returns: the View factory for the given Localethe target locale)LocaleInitialize the View |
| protected View | loadView(String
the name of the view to retrieve viewName, Locale the Locale to retrieve the view for locale)Implements abstract org. Subclasses must implement this method, building a View object for the specified view. |
| public void | |
| public void | setBasenames(String... basenames)
Set an array of basenames, each following |
| public void | |
| public void | setDefaultParentView(String defaultParentView)
Set the default parent for views defined in the |
| public void | setLocalesToInitialize(Locale... localesToInitialize)
Specify Locales to initialize eagerly, rather than lazily when actually accessed. |
| public void |
| basenames | back to summary |
|---|---|
| private String[] basenames | |
| bundleCache | back to summary |
|---|---|
| private final Map<List<ResourceBundle>, ConfigurableApplicationContext> bundleCache | |
| bundleClassLoader | back to summary |
|---|---|
| private ClassLoader bundleClassLoader | |
| DEFAULT_BASENAME | back to summary |
|---|---|
| public static final String DEFAULT_BASENAME The default basename if no other basename is supplied. | |
| defaultParentView | back to summary |
|---|---|
| private String defaultParentView
| |
| localeCache | back to summary |
|---|---|
| private final Map<Locale, BeanFactory> localeCache | |
| localesToInitialize | back to summary |
|---|---|
| private Locale[] localesToInitialize
| |
| order | back to summary |
|---|---|
| private int order | |
| ResourceBundleViewResolver | back to summary |
|---|---|
| public ResourceBundleViewResolver() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws BeansException Implements org. Eagerly initialize Locales if necessary.
| |
| destroy | back to summary |
|---|---|
| public void destroy() throws BeansException Implements org. Close the bundle View factories on context shutdown.
| |
| getBundle | back to summary |
|---|---|
| protected ResourceBundle getBundle(String basename, Locale locale) throws MissingResourceException Obtain the resource bundle for the given basename and
| |
| getBundleClassLoader | back to summary |
|---|---|
| protected ClassLoader getBundleClassLoader() Return the Default is the specified bundle | |
| getOrder | back to summary |
|---|---|
| public int getOrder() Implements org. Doc from org. Get the order value of this object. Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet Same order values will result in arbitrary sort positions for the affected objects.
| |
| initFactory | back to summary |
|---|---|
| protected synchronized BeanFactory initFactory(Locale locale) throws BeansException Initialize the View Synchronized because of access by parallel threads.
| |
| loadView | back to summary |
|---|---|
| protected View loadView(String viewName, Locale locale) throws Exception Implements abstract org. Doc from org. 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. | |
| setBasename | back to summary |
|---|---|
| public void setBasename(String basename) Set a single basename, following
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 | |
| setBasenames | back to summary |
|---|---|
| public void setBasenames(String... basenames) Set an array of basenames, each following
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 | |
| setBundleClassLoader | back to summary |
|---|---|
| public void setBundleClassLoader(ClassLoader classLoader) Set the | |
| setDefaultParentView | back to summary |
|---|---|
| public void setDefaultParentView(String defaultParentView) Set the default parent for views defined in the 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 a 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 compatibility reasons. It still matches the typical use case. | |
| setLocalesToInitialize | back to summary |
|---|---|
| public void setLocalesToInitialize(Locale... localesToInitialize) 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. | |
| setOrder | back to summary |
|---|---|
| public void setOrder(int order) Specify the order value for this ViewResolver bean. The default value is | |