Top Description Fields Constructors Methods
org.springframework.web.servlet.mvc

public abstract Class AbstractUrlViewController

extends AbstractController
Class Inheritance
Known Direct Subclasses
org.springframework.web.servlet.mvc.UrlFilenameViewController
Imports
jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.util.Assert, org.springframework.web.servlet.ModelAndView, org.springframework.web.servlet.support.RequestContextUtils, org.springframework.web.util.UrlPathHelper

Abstract base class for Controllers that return a view name based on the request URL.

Provides infrastructure for determining view names from URLs and configurable URL lookup. For information on the latter, see alwaysUseFullPath and urlDecode properties.

Author
Juergen Hoeller
Since
1.2.6
See Also
setAlwaysUseFullPath, setUrlDecode

Field Summary

Modifier and TypeField and Description
private UrlPathHelper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected UrlPathHelper
getUrlPathHelper()

Return the UrlPathHelper to use for the resolution of lookup paths.

protected abstract String

Returns:

a view name for this request (never null)
getViewNameForRequest
(HttpServletRequest
current HTTP request
request
)

Return the name of the view to render for this request, based on the given lookup path.

protected ModelAndView
public void
setAlwaysUseFullPath(boolean alwaysUseFullPath)

Set if URL lookup should always use full path within current servlet context.

public void
setRemoveSemicolonContent(boolean removeSemicolonContent)

Set if ";" (semicolon) content should be stripped from the request URI.

public void
setUrlDecode(boolean urlDecode)

Set if context path and request URI should be URL-decoded.

public void
setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use for the resolution of lookup paths.

Inherited from org.springframework.web.servlet.mvc.AbstractController:
handleRequestisSynchronizeOnSessionsetSynchronizeOnSession

Field Detail

urlPathHelperback to summary
private UrlPathHelper urlPathHelper

Constructor Detail

AbstractUrlViewControllerback to summary
public AbstractUrlViewController()

Method Detail

getUrlPathHelperback to summary
protected UrlPathHelper getUrlPathHelper()

Return the UrlPathHelper to use for the resolution of lookup paths.

getViewNameForRequestback to summary
protected abstract String getViewNameForRequest(HttpServletRequest request)

Return the name of the view to render for this request, based on the given lookup path. Called by handleRequestInternal.

Parameters
request:HttpServletRequest

current HTTP request

Returns:String

a view name for this request (never null)

See Also
handleRequestInternal, setAlwaysUseFullPath, setUrlDecode
handleRequestInternalback to summary
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)

Implements abstract org.springframework.web.servlet.mvc.AbstractController.handleRequestInternal.

Retrieves the URL path to use for lookup and delegates to getViewNameForRequest. Also adds the content of RequestContextUtils#getInputFlashMap to the model.

Annotations
@Override
setAlwaysUseFullPathback to summary
public void setAlwaysUseFullPath(boolean alwaysUseFullPath)

Set if URL lookup should always use full path within current servlet context. Else, the path within the current servlet mapping is used if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml). Default is "false".

See Also
org.springframework.web.util.UrlPathHelper#setAlwaysUseFullPath
setRemoveSemicolonContentback to summary
public void setRemoveSemicolonContent(boolean removeSemicolonContent)

Set if ";" (semicolon) content should be stripped from the request URI.

See Also
org.springframework.web.util.UrlPathHelper#setRemoveSemicolonContent(boolean)
setUrlDecodeback to summary
public void setUrlDecode(boolean urlDecode)

Set if context path and request URI should be URL-decoded. Both are returned undecoded by the Servlet API, in contrast to the servlet path.

Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).

See Also
org.springframework.web.util.UrlPathHelper#setUrlDecode
setUrlPathHelperback to summary
public void setUrlPathHelper(UrlPathHelper urlPathHelper)

Set the UrlPathHelper to use for the resolution of lookup paths.

Use this to override the default UrlPathHelper with a custom subclass, or to share common UrlPathHelper settings across multiple MethodNameResolvers and HandlerMappings.

See Also
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping#setUrlPathHelper