org.springframework.web.servlet.view
Class UrlBasedViewResolver

org.springframework.context.support.ApplicationObjectSupport
  |
  +--org.springframework.web.context.support.WebApplicationObjectSupport
        |
        +--org.springframework.web.servlet.view.AbstractCachingViewResolver
              |
              +--org.springframework.web.servlet.view.UrlBasedViewResolver
Direct Known Subclasses:
InternalResourceViewResolver, VelocityViewResolver

public class UrlBasedViewResolver
extends AbstractCachingViewResolver

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.

Author:
Juergen Hoeller
Since: 13.12.2003
See Also: setViewClass(java.lang.Class), setPrefix(java.lang.String), setSuffix(java.lang.String), setRequestContextAttribute(java.lang.String), AbstractUrlBasedView

Method Summary
 voidsetContentType(String contentType)
          Set the content type for all views.
 voidsetPrefix(String prefix)
          Set the prefix that gets applied to view names when building a URL.
 voidsetRequestContextAttribute(String requestContextAttribute)
          Set the name of the RequestContext attribute for all views.
 voidsetSuffix(String suffix)
          Set the suffix that gets applied to view names when building a URL.
 voidsetViewClass(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.context.support.ApplicationObjectSupport
getApplicationContext, setApplicationContext

Method Detail

setContentType

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. in case of JSPs.
Parameters:
contentType - the content type

setPrefix

public void setPrefix(String prefix)
Set the prefix that gets applied to view names when building a URL.
Parameters:
prefix - view name prefix

setRequestContextAttribute

public void setRequestContextAttribute(String requestContextAttribute)
Set the name of the RequestContext attribute for all views.
Parameters:
requestContextAttribute - name of the RequestContext attribute

setSuffix

public void setSuffix(String suffix)
Set the suffix that gets applied to view names when building a URL.
Parameters:
suffix - view name suffix

setViewClass

public void setViewClass(Class viewClass)
Set the view class that should be used to create views.
Parameters:
viewClass - class that is assignable to InternalResourceView

Association Links

to Class java.lang.Class

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String