UrlBasedViewResolver that supports
InternalResourceView (i.e. Servlets and JSPs) and subclasses
such as JstlView.
The view class for all views generated by this resolver can be specified
via setViewClass. See UrlBasedViewResolver's javadoc for details.
The default is InternalResourceView, or JstlView if the
JSTL API is present.
BTW, it's good practice to put JSP files that just serve as views under WEB-INF, to hide them from direct access (e.g. via a manually entered URL). Only controllers will be able to access them then.
Note
When chaining ViewResolvers, an InternalResourceViewResolver always needs to be last, as it will attempt to resolve any view name, no matter whether the underlying resource actually exists.
setViewClass, setPrefix, setSuffix, setRequestContextAttribute, InternalResourceView, JstlView
| Modifier and Type | Field and Description |
|---|---|
| private Boolean | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | InternalResourceViewResolver()
Sets the default |
| public | InternalResourceViewResolver(String
the prefix that gets prepended to view names when building a URL prefix, String the suffix that gets appended to view names when building a URL suffix)A convenience constructor that allows for specifying |
| Modifier and Type | Method and Description |
|---|---|
| protected AbstractUrlBasedView | buildView(String
the name of the view to build viewName)Overrides org. Creates a new View instance of the specified view class and configures it. |
| protected AbstractUrlBasedView | instantiateView()
Overrides org. Instantiate the specified view class. |
| protected Class | requiredViewClass()
Overrides org. Return the required type of view for this resolver. |
| public void | setAlwaysInclude(boolean alwaysInclude)
Specify whether to always include the view rather than forward to it. |
| alwaysInclude | back to summary |
|---|---|
| private Boolean alwaysInclude
| |
| jstlPresent | back to summary |
|---|---|
| private static final boolean jstlPresent | |
| InternalResourceViewResolver | back to summary |
|---|---|
| public InternalResourceViewResolver() Sets the default | |
| InternalResourceViewResolver | back to summary |
|---|---|
| public InternalResourceViewResolver(String prefix, String suffix) A convenience constructor that allows for specifying | |
| buildView | back to summary |
|---|---|
| protected AbstractUrlBasedView buildView(String viewName) throws Exception Overrides org. Doc from org. Creates a new View instance of the specified view class and configures it. Does not perform any lookup for pre-defined View instances. Spring lifecycle methods as defined by the bean container do not have to
be called here; those will be applied by the Subclasses will typically call
| |
| instantiateView | back to summary |
|---|---|
| protected AbstractUrlBasedView instantiateView() Overrides org. Doc from org. Instantiate the specified view class. The default implementation uses reflection to instantiate the class.
| |
| requiredViewClass | back to summary |
|---|---|
| protected Class Overrides org. Doc from org. Return the required type of view for this resolver.
This implementation returns
| |
| setAlwaysInclude | back to summary |
|---|---|
| public void setAlwaysInclude(boolean alwaysInclude) Specify whether to always include the view rather than forward to it. Default is "false". Switch this flag on to enforce the use of a Servlet include, even if a forward would be possible. | |