Package org.springframework.web.servlet.view

# Class ResourceBundleViewResolver

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

All Implemented Interfaces:
  `org.springframework.beans.factory.Aware`, `org.springframework.beans.factory.DisposableBean`, `org.springframework.beans.factory.InitializingBean`, `org.springframework.context.ApplicationContextAware`, `org.springframework.core.Ordered`, `org.springframework.web.context.ServletContextAware`, `ViewResolver`

@Deprecated public class ResourceBundleViewResolver extends AbstractCachingViewResolver implements org.springframework.core.Ordered, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Deprecated.
as of 5.3, in favor of Spring's common view resolver variants and/or custom resolver implementations
A `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 `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 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`.

Author:
  Rod Johnson, Juergen Hoeller
See Also:
  - `ResourceBundle.getBundle(java.lang.String)`
  - `PropertyResourceBundle`
  - `UrlBasedViewResolver`
  - `BeanNameViewResolver`

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

`AbstractCachingViewResolver.CacheFilter`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_BASENAME`
Deprecated.
The default basename if no other basename is supplied.

### Fields inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

`DEFAULT_CACHE_LIMIT`

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

## Constructor Summary

Constructors
Constructor
Description
`ResourceBundleViewResolver()`
Deprecated.

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
Deprecated.
Eagerly initialize Locales if necessary.
`void`
`destroy()`
Deprecated.
Close the bundle View factories on context shutdown.
`protected ResourceBundle`
`getBundle(String basename, Locale locale)`
Deprecated.
Obtain the resource bundle for the given basename and `Locale`.
`protected ClassLoader`
`getBundleClassLoader()`
Deprecated.
Return the `ClassLoader` to load resource bundles with.
`int`
`getOrder()`
Deprecated.
`protected org.springframework.beans.factory.BeanFactory`
`initFactory(Locale locale)`
Deprecated.
Initialize the View `BeanFactory` from the `ResourceBundle`, for the given `locale`.
`protected View`
`loadView(String viewName, Locale locale)`
Deprecated.
Subclasses must implement this method, building a View object for the specified view.
`void`
`setBasename(String basename)`
Deprecated.
Set a single basename, following `ResourceBundle` conventions.
`void`
`setBasenames(String... basenames)`
Deprecated.
Set an array of basenames, each following `ResourceBundle` conventions.
`void`
`setBundleClassLoader(ClassLoader classLoader)`
Deprecated.
Set the `ClassLoader` to load resource bundles with.
`void`
`setDefaultParentView(String defaultParentView)`
Deprecated.
Set the default parent for views defined in the `ResourceBundle`.
`void`
`setLocalesToInitialize(Locale... localesToInitialize)`
Deprecated.
Specify Locales to initialize eagerly, rather than lazily when actually accessed.
`void`
`setOrder(int order)`
Deprecated.
Specify the order value for this ViewResolver bean.

### Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

`clearCache, createView, getCacheFilter, getCacheKey, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, setCacheFilter, setCacheLimit, setCacheUnresolved`

### Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

`getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext`

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_BASENAME

public static final String DEFAULT_BASENAME
Deprecated.
The default basename if no other basename is supplied.

See Also:
  - Constant Field Values

## Constructor Details

### ResourceBundleViewResolver

public ResourceBundleViewResolver()
Deprecated.

## Method Details

### setBasename

public void setBasename(String basename)
Deprecated.
Set a single basename, following `ResourceBundle` conventions. The default is "views".

`ResourceBundle` supports different locale 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.

See Also:
  - `setBasenames(java.lang.String...)`
  - `ResourceBundle.getBundle(String)`
  - `ResourceBundle.getBundle(String, Locale)`

### setBasenames

public void setBasenames(String... basenames)
Deprecated.
Set an array of basenames, each following `ResourceBundle` conventions. The default is a single basename "views".

`ResourceBundle` supports different locale 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.

See Also:
  - `setBasename(java.lang.String)`
  - `ResourceBundle.getBundle(String)`
  - `ResourceBundle.getBundle(String, Locale)`

### setBundleClassLoader

public void setBundleClassLoader(ClassLoader classLoader)
Deprecated.
Set the `ClassLoader` to load resource bundles with. Default is the thread context `ClassLoader`.

### getBundleClassLoader

protected ClassLoader getBundleClassLoader()
Deprecated.
Return the `ClassLoader` to load resource bundles with.

Default is the specified bundle `ClassLoader`, usually the thread context `ClassLoader`.

### setDefaultParentView

public void setDefaultParentView(String defaultParentView)
Deprecated.
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 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

public void setLocalesToInitialize(Locale... localesToInitialize)
Deprecated.
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

public void setOrder(int order)
Deprecated.
Specify the order value for this ViewResolver bean.

The default value is `Ordered.LOWEST_PRECEDENCE`, meaning non-ordered.

See Also:
  - `Ordered.getOrder()`

### getOrder

public int getOrder()
Deprecated.

Specified by:
  `getOrder` in interface `org.springframework.core.Ordered`

### afterPropertiesSet

public void afterPropertiesSet() throws org.springframework.beans.BeansException
Deprecated.
Eagerly initialize Locales if necessary.

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `org.springframework.beans.BeansException`
See Also:
  - `setLocalesToInitialize(java.util.Locale...)`

### loadView

@Nullable protected View loadView(String viewName, Locale locale) throws Exception
Deprecated.
Description copied from class: `AbstractCachingViewResolver`
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.

Specified by:
  `loadView` in class `AbstractCachingViewResolver`
Parameters:
  `viewName` - the name of the view to retrieve
  `locale` - the Locale to retrieve the view for
Returns:
  the View instance, or `null` if not found (optional, to allow for ViewResolver chaining)
Throws:
  `Exception` - if the view couldn't be resolved
See Also:
  - `AbstractCachingViewResolver.resolveViewName(java.lang.String, java.util.Locale)`

### initFactory

protected org.springframework.beans.factory.BeanFactory initFactory(Locale locale) throws org.springframework.beans.BeansException
Deprecated.
Initialize the View `BeanFactory` from the `ResourceBundle`, for the given `locale`.

Synchronized because of access by parallel threads.

Parameters:
  `locale` - the target `Locale`
Returns:
  the View factory for the given Locale
Throws:
  `org.springframework.beans.BeansException` - in case of initialization errors

### getBundle

protected ResourceBundle getBundle(String basename, Locale locale) throws MissingResourceException
Deprecated.
Obtain the resource bundle for the given basename and `Locale`.

Parameters:
  `basename` - the basename to look for
  `locale` - the `Locale` to look for
Returns:
  the corresponding `ResourceBundle`
Throws:
  `MissingResourceException` - if no matching bundle could be found
See Also:
  - `ResourceBundle.getBundle(String, Locale, ClassLoader)`

### destroy

public void destroy() throws org.springframework.beans.BeansException
Deprecated.
Close the bundle View factories on context shutdown.

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`
Throws:
  `org.springframework.beans.BeansException`