org.hdiv.web.servlet.view
Class UrlBasedViewResolverHDIV
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.UrlBasedViewResolver
org.hdiv.web.servlet.view.UrlBasedViewResolverHDIV
- All Implemented Interfaces:
- org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.ViewResolver
public class UrlBasedViewResolverHDIV
- extends org.springframework.web.servlet.view.UrlBasedViewResolver
Simple implementation of the 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.
- Since:
- HDIV 2.0.3
- Author:
- Gorka Vicente
- See Also:
UrlBasedViewResolver.setViewClass(java.lang.Class),
UrlBasedViewResolver.setPrefix(java.lang.String),
UrlBasedViewResolver.setSuffix(java.lang.String),
UrlBasedViewResolver.setRequestContextAttribute(java.lang.String),
UrlBasedViewResolver.REDIRECT_URL_PREFIX,
AbstractUrlBasedView,
InternalResourceView,
org.springframework.web.servlet.view.velocity.VelocityView,
org.springframework.web.servlet.view.freemarker.FreeMarkerView
| Fields inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver |
FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX |
| Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
| Fields inherited from interface org.springframework.core.Ordered |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
|
Method Summary |
protected org.springframework.web.servlet.View |
createView(java.lang.String viewName,
java.util.Locale locale)
Overridden to implement check for "redirect:" prefix. |
| Methods inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver |
buildView, canHandle, getAttributesMap, getCacheKey, getContentType, getOrder, getPrefix, getRequestContextAttribute, getSuffix, getViewClass, getViewNames, initApplicationContext, isRedirectContextRelative, isRedirectHttp10Compatible, loadView, requiredViewClass, setAttributes, setAttributesMap, setContentType, setOrder, setPrefix, setRedirectContextRelative, setRedirectHttp10Compatible, setRequestContextAttribute, setSuffix, setViewClass, setViewNames |
| Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver |
clearCache, isCache, removeFromCache, resolveViewName, setCache |
| Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext |
| Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UrlBasedViewResolverHDIV
public UrlBasedViewResolverHDIV()
createView
protected org.springframework.web.servlet.View createView(java.lang.String viewName,
java.util.Locale locale)
throws java.lang.Exception
- Overridden to implement check for "redirect:" prefix.
Not possible in loadView, since overridden
loadView versions in subclasses might rely on the
superclass always creating instances of the required view class.
- Overrides:
createView in class org.springframework.web.servlet.view.UrlBasedViewResolver
- Throws:
java.lang.Exception- See Also:
UrlBasedViewResolver.loadView(java.lang.String, java.util.Locale),
UrlBasedViewResolver.requiredViewClass()
Copyright © 2008 hdiv.org. All Rights Reserved.