| org.springframework.web.servlet.view.AbstractCachingViewResolver org.springframework.web.servlet.view.UrlBasedViewResolver
All known Subclasses: org.springframework.web.servlet.view.AbstractTemplateViewResolver, org.springframework.web.servlet.view.xslt.XsltViewResolver, org.springframework.web.servlet.view.jasperreports.JasperReportsViewResolver, org.springframework.web.servlet.view.InternalResourceViewResolver,
UrlBasedViewResolver | public class UrlBasedViewResolver extends AbstractCachingViewResolver implements Ordered(Code) | | Simple implementation of the
org.springframework.web.servlet.ViewResolver interface, allowing for direct resolution of symbolic view names to URLs,
without explicit mapping definition. This is useful if your symbolic names
match the names of your view resources in a straightforward manner
(i.e. the symbolic name is the unique part of the resource's filename),
without the need for a dedicated mapping to be defined for each view.
Supports
AbstractUrlBasedView subclasses like
InternalResourceView ,
org.springframework.web.servlet.view.velocity.VelocityView and
org.springframework.web.servlet.view.freemarker.FreeMarkerView .
The view class for all views generated by this resolver can be specified
via the "viewClass" property.
View names can either be resource URLs themselves, or get augmented by a
specified prefix and/or suffix. Exporting an attribute that holds the
RequestContext to all views is explicitly supported.
Example: prefix="/WEB-INF/jsp/", suffix=".jsp", viewname="test" ->
"/WEB-INF/jsp/test.jsp"
As a special feature, redirect URLs can be specified via the "redirect:"
prefix. E.g.: "redirect:myAction.do" will trigger a redirect to the given
URL, rather than resolution as standard view name. This is typically used
for redirecting to a controller URL after finishing a form workflow.
Furthermore, forward URLs can be specified via the "forward:" prefix. E.g.:
"forward:myAction.do" will trigger a forward to the given URL, rather than
resolution as standard view name. This is typically used for controller URLs;
it is not supposed to be used for JSP URLs - use logical view names there.
Note: This class does not support localized resolution, i.e. resolving
a symbolic view name to different resources depending on the current locale.
Note: When chaining ViewResolvers, a UrlBasedViewResolver always needs
to be last, as it will attempt to resolve any view name, no matter whether
the underlying resource actually exists.
author: Juergen Hoeller author: Rob Harrop since: 13.12.2003 See Also: UrlBasedViewResolver.setViewClass See Also: UrlBasedViewResolver.setPrefix See Also: UrlBasedViewResolver.setSuffix See Also: UrlBasedViewResolver.setRequestContextAttribute See Also: UrlBasedViewResolver.REDIRECT_URL_PREFIX See Also: AbstractUrlBasedView See Also: InternalResourceView See Also: org.springframework.web.servlet.view.velocity.VelocityView See Also: org.springframework.web.servlet.view.freemarker.FreeMarkerView |
Field Summary | |
final public static String | FORWARD_URL_PREFIX Prefix for special view names that specify a forward URL (usually
to a controller after a form has been submitted and processed). | final public static String | REDIRECT_URL_PREFIX Prefix for special view names that specify a redirect URL (usually
to a controller after a form has been submitted and processed). |
Method Summary | |
protected AbstractUrlBasedView | buildView(String viewName) 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 loadView method
after this method returns.
Subclasses will typically call super.buildView(viewName)
first, before setting further properties themselves. | protected boolean | canHandle(String viewName, Locale locale) Indicates whether or not this
org.springframework.web.servlet.ViewResolver can
handle the supplied view name. | protected View | createView(String viewName, Locale locale) Overridden to implement check for "redirect:" prefix. | public Map | getAttributesMap() Allow Map access to the static attributes for views returned by
this resolver, with the option to add or override specific entries.
Useful for specifying entries directly, for example via
"attributesMap[myKey]". | protected Object | getCacheKey(String viewName, Locale locale) This implementation returns just the view name,
as this ViewResolver doesn't support localized resolution. | protected String | getContentType() Return the content type for all views, if any. | public int | getOrder() Return the order in which this
org.springframework.web.servlet.ViewResolver is evaluated. | protected String | getPrefix() Return the prefix that gets prepended to view names when building a URL. | protected String | getRequestContextAttribute() Return the name of the RequestContext attribute for all views, if any. | protected String | getSuffix() Return the suffix that gets appended to view names when building a URL. | protected Class | getViewClass() Return the view class to be used to create views. | protected String[] | getViewNames() Return the view names (or name patterns) that can be handled by this
org.springframework.web.servlet.ViewResolver . | protected void | initApplicationContext() | protected boolean | isRedirectContextRelative() Return whether to interpret a given redirect URL that starts with a
slash ("/") as relative to the current ServletContext, i.e. | protected boolean | isRedirectHttp10Compatible() Return whether redirects should stay compatible with HTTP 1.0 clients. | protected View | loadView(String viewName, Locale locale) | protected Class | requiredViewClass() Return the required type of view for this resolver. | public void | setAttributes(Properties props) Set static attributes from a java.util.Properties object,
for all views returned by this resolver.
This is the most convenient way to set static attributes. | public void | setAttributesMap(Map attributes) Set static attributes from a Map, for all views returned by this resolver. | public void | setContentType(String contentType) Set the content type for all views.
May be ignored by view classes if the view itself is assumed
to set the content type, e.g. | public void | setOrder(int order) Set the order in which this
org.springframework.web.servlet.ViewResolver is evaluated. | public void | setPrefix(String prefix) Set the prefix that gets prepended to view names when building a URL. | public void | setRedirectContextRelative(boolean redirectContextRelative) Set whether to interpret a given redirect URL that starts with a
slash ("/") as relative to the current ServletContext, i.e. | public void | setRedirectHttp10Compatible(boolean redirectHttp10Compatible) Set whether redirects should stay compatible with HTTP 1.0 clients.
In the default implementation, this will enforce HTTP status code 302
in any case, i.e. | public void | setRequestContextAttribute(String requestContextAttribute) Set the name of the RequestContext attribute for all views. | public void | setSuffix(String suffix) Set the suffix that gets appended to view names when building a URL. | public void | setViewClass(Class viewClass) Set the view class that should be used to create views. | public void | setViewNames(String[] viewNames) Set the view names (or name patterns) that can be handled by this
org.springframework.web.servlet.ViewResolver . |
FORWARD_URL_PREFIX | final public static String FORWARD_URL_PREFIX(Code) | | Prefix for special view names that specify a forward URL (usually
to a controller after a form has been submitted and processed).
Such view names will not be resolved in the configured default
way but rather be treated as special shortcut.
|
REDIRECT_URL_PREFIX | final public static String REDIRECT_URL_PREFIX(Code) | | Prefix for special view names that specify a redirect URL (usually
to a controller after a form has been submitted and processed).
Such view names will not be resolved in the configured default
way but rather be treated as special shortcut.
|
buildView | protected AbstractUrlBasedView buildView(String viewName) throws Exception(Code) | | 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 loadView method
after this method returns.
Subclasses will typically call super.buildView(viewName)
first, before setting further properties themselves. loadView
will then apply Spring lifecycle methods at the end of this process.
Parameters: viewName - the name of the view to build the View instance throws: Exception - if the view couldn't be resolved See Also: UrlBasedViewResolver.loadView(String,java.util.Locale) |
getAttributesMap | public Map getAttributesMap()(Code) | | Allow Map access to the static attributes for views returned by
this resolver, with the option to add or override specific entries.
Useful for specifying entries directly, for example via
"attributesMap[myKey]". This is particularly useful for
adding or overriding entries in child view definitions.
|
getCacheKey | protected Object getCacheKey(String viewName, Locale locale)(Code) | | This implementation returns just the view name,
as this ViewResolver doesn't support localized resolution.
|
getContentType | protected String getContentType()(Code) | | Return the content type for all views, if any.
|
getPrefix | protected String getPrefix()(Code) | | Return the prefix that gets prepended to view names when building a URL.
|
getRequestContextAttribute | protected String getRequestContextAttribute()(Code) | | Return the name of the RequestContext attribute for all views, if any.
|
getSuffix | protected String getSuffix()(Code) | | Return the suffix that gets appended to view names when building a URL.
|
getViewClass | protected Class getViewClass()(Code) | | Return the view class to be used to create views.
|
initApplicationContext | protected void initApplicationContext()(Code) | | |
isRedirectContextRelative | protected boolean isRedirectContextRelative()(Code) | | Return whether to interpret a given redirect URL that starts with a
slash ("/") as relative to the current ServletContext, i.e. as
relative to the web application root.
|
isRedirectHttp10Compatible | protected boolean isRedirectHttp10Compatible()(Code) | | Return whether redirects should stay compatible with HTTP 1.0 clients.
|
requiredViewClass | protected Class requiredViewClass()(Code) | | Return the required type of view for this resolver.
This implementation returns AbstractUrlBasedView.
See Also: AbstractUrlBasedView |
setAttributes | public void setAttributes(Properties props)(Code) | | Set static attributes from a java.util.Properties object,
for all views returned by this resolver.
This is the most convenient way to set static attributes. Note that
static attributes can be overridden by dynamic attributes, if a value
with the same name is included in the model.
Can be populated with a String "value" (parsed via PropertiesEditor)
or a "props" element in XML bean definitions.
See Also: org.springframework.beans.propertyeditors.PropertiesEditor See Also: AbstractView.setAttributes |
setAttributesMap | public void setAttributesMap(Map attributes)(Code) | | Set static attributes from a Map, for all views returned by this resolver.
This allows to set any kind of attribute values, for example bean references.
Can be populated with a "map" or "props" element in XML bean definitions.
Parameters: attributes - Map with name Strings as keys and attribute objects as values See Also: AbstractView.setAttributesMap |
setContentType | public void setContentType(String contentType)(Code) | | Set the content type for all views.
May be ignored by view classes if the view itself is assumed
to set the content type, e.g. in case of JSPs.
|
setPrefix | public void setPrefix(String prefix)(Code) | | Set the prefix that gets prepended to view names when building a URL.
|
setRedirectContextRelative | public void setRedirectContextRelative(boolean redirectContextRelative)(Code) | | Set whether to interpret a given redirect URL that starts with a
slash ("/") as relative to the current ServletContext, i.e. as
relative to the web application root.
Default is "true": A redirect URL that starts with a slash will be
interpreted as relative to the web application root, i.e. the context
path will be prepended to the URL.
Redirect URLs can be specified via the "redirect:" prefix.
E.g.: "redirect:myAction.do"
See Also: RedirectView.setContextRelative See Also: UrlBasedViewResolver.REDIRECT_URL_PREFIX |
setRedirectHttp10Compatible | public void setRedirectHttp10Compatible(boolean redirectHttp10Compatible)(Code) | | Set whether redirects should stay compatible with HTTP 1.0 clients.
In the default implementation, this will enforce HTTP status code 302
in any case, i.e. delegate to HttpServletResponse.sendRedirect .
Turning this off will send HTTP status code 303, which is the correct
code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.
Many HTTP 1.1 clients treat 302 just like 303, not making any
difference. However, some clients depend on 303 when redirecting
after a POST request; turn this flag off in such a scenario.
Redirect URLs can be specified via the "redirect:" prefix.
E.g.: "redirect:myAction.do"
See Also: RedirectView.setHttp10Compatible See Also: UrlBasedViewResolver.REDIRECT_URL_PREFIX |
setRequestContextAttribute | public void setRequestContextAttribute(String requestContextAttribute)(Code) | | Set the name of the RequestContext attribute for all views.
Parameters: requestContextAttribute - name of the RequestContext attribute See Also: AbstractView.setRequestContextAttribute |
setSuffix | public void setSuffix(String suffix)(Code) | | Set the suffix that gets appended to view names when building a URL.
|
setViewClass | public void setViewClass(Class viewClass)(Code) | | Set the view class that should be used to create views.
Parameters: viewClass - class that is assignable to the required view class(by default, AbstractUrlBasedView) See Also: AbstractUrlBasedView |
|
|