|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
Simple implementation of ViewResolver that allows for direct resolution of symbolic view names to URLs, without explicit mapping definition. This is appropriate if your symbolic names match the names of your view resources in a straightforward manner, without the need for arbitrary mappings.
Supports AbstractUrlBasedView subclasses like InternalResourceView and VelocityView. The view class for all views generated by this resolver can be specified via setViewClass.
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"
Note: This class does not support localized resolution, i.e. resolving a symbolic view name to different resources depending on the current locale.
setViewClass(java.lang.Class)
,
setPrefix(java.lang.String)
,
setSuffix(java.lang.String)
,
setRequestContextAttribute(java.lang.String)
,
AbstractUrlBasedView
Field Summary |
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
logger |
Constructor Summary | |
UrlBasedViewResolver()
|
Method Summary | |
protected java.lang.String |
getCacheKey(java.lang.String viewName,
java.util.Locale locale)
This implementation returns just the view name, as InternalResourceViewResolver doesn't support localized resolution. |
protected View |
loadView(java.lang.String viewName,
java.util.Locale locale)
Subclasses must implement this method. |
protected java.lang.Class |
requiredViewClass()
Return the required type of view for this resolver. |
void |
setContentType(java.lang.String contentType)
Set the content type for all views. |
void |
setPrefix(java.lang.String prefix)
Set the prefix that gets applied to view names when building a URL. |
void |
setRequestContextAttribute(java.lang.String requestContextAttribute)
Set the name of the RequestContext attribute for all views. |
void |
setSuffix(java.lang.String suffix)
Set the suffix that gets applied to view names when building a URL. |
void |
setViewClass(java.lang.Class viewClass)
Set the view class that should be used to create views. |
Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver |
isCache, resolveViewName, setCache |
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass |
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport |
getApplicationContext, getMessageSourceAccessor, initApplicationContext, setApplicationContext |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UrlBasedViewResolver()
Method Detail |
public void setViewClass(java.lang.Class viewClass)
viewClass
- class that is assignable to InternalResourceViewprotected java.lang.Class requiredViewClass()
AbstractUrlBasedView
public void setPrefix(java.lang.String prefix)
prefix
- view name prefixpublic void setSuffix(java.lang.String suffix)
suffix
- view name suffixpublic void setContentType(java.lang.String contentType)
contentType
- the content typepublic void setRequestContextAttribute(java.lang.String requestContextAttribute)
requestContextAttribute
- name of the RequestContext attributeprotected java.lang.String getCacheKey(java.lang.String viewName, java.util.Locale locale)
getCacheKey
in class AbstractCachingViewResolver
protected View loadView(java.lang.String viewName, java.util.Locale locale)
AbstractCachingViewResolver
loadView
in class AbstractCachingViewResolver
viewName
- the name of the view to retrievelocale
- the Locale to retrieve the view for
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |