Package org.springframework.web.servlet.mvc

# Class AbstractUrlViewController

java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.support.WebContentGenerator
org.springframework.web.servlet.mvc.AbstractController
org.springframework.web.servlet.mvc.AbstractUrlViewController

All Implemented Interfaces:
  `org.springframework.beans.factory.Aware`, `org.springframework.context.ApplicationContextAware`, `org.springframework.web.context.ServletContextAware`, `Controller`

Direct Known Subclasses:
  `UrlFilenameViewController`

public abstract class AbstractUrlViewController extends AbstractController
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.

Since:
  1.2.6
Author:
  Juergen Hoeller
See Also:
  - `setAlwaysUseFullPath(boolean)`
  - `setUrlDecode(boolean)`

## Field Summary

### Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator

`HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST`

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

## Constructor Summary

Constructors
Constructor
Description
`AbstractUrlViewController()`

## Method Summary

Modifier and Type
Method
Description
`protected org.springframework.web.util.UrlPathHelper`
`getUrlPathHelper()`
Return the UrlPathHelper to use for the resolution of lookup paths.
`protected abstract String`
`getViewNameForRequest(HttpServletRequest request)`
Return the name of the view to render for this request, based on the given lookup path.
`protected ModelAndView`
`handleRequestInternal(HttpServletRequest request, HttpServletResponse response)`
Retrieves the URL path to use for lookup and delegates to `getViewNameForRequest(jakarta.servlet.http.HttpServletRequest)`.
`void`
`setAlwaysUseFullPath(boolean alwaysUseFullPath)`
Set if URL lookup should always use full path within current servlet context.
`void`
`setRemoveSemicolonContent(boolean removeSemicolonContent)`
Set if ";" (semicolon) content should be stripped from the request URI.
`void`
`setUrlDecode(boolean urlDecode)`
Set if context path and request URI should be URL-decoded.
`void`
`setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper)`
Set the UrlPathHelper to use for the resolution of lookup paths.

### Methods inherited from class org.springframework.web.servlet.mvc.AbstractController

`handleRequest, isSynchronizeOnSession, setSynchronizeOnSession`

### Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator

`applyCacheControl, applyCacheSeconds, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isRequireSession, prepareResponse, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setVaryByRequestHeaders`

### Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

`getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext`

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AbstractUrlViewController

public AbstractUrlViewController()

## Method Details

### setAlwaysUseFullPath

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:
  - `UrlPathHelper.setAlwaysUseFullPath(boolean)`

### setUrlDecode

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:
  - `UrlPathHelper.setUrlDecode(boolean)`

### setRemoveSemicolonContent

public void setRemoveSemicolonContent(boolean removeSemicolonContent)
Set if ";" (semicolon) content should be stripped from the request URI.

See Also:
  - `UrlPathHelper.setRemoveSemicolonContent(boolean)`

### setUrlPathHelper

public void setUrlPathHelper(org.springframework.web.util.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:
  - `AbstractHandlerMapping.setUrlPathHelper(org.springframework.web.util.UrlPathHelper)`

### getUrlPathHelper

protected org.springframework.web.util.UrlPathHelper getUrlPathHelper()
Return the UrlPathHelper to use for the resolution of lookup paths.

### handleRequestInternal

protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
Retrieves the URL path to use for lookup and delegates to `getViewNameForRequest(jakarta.servlet.http.HttpServletRequest)`. Also adds the content of `RequestContextUtils.getInputFlashMap(jakarta.servlet.http.HttpServletRequest)` to the model.

Specified by:
  `handleRequestInternal` in class `AbstractController`
See Also:
  - `AbstractController.handleRequest(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)`

### getViewNameForRequest

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(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)`.

Parameters:
  `request` - current HTTP request
Returns:
  a view name for this request (never `null`)
See Also:
  - `handleRequestInternal(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)`
  - `setAlwaysUseFullPath(boolean)`
  - `setUrlDecode(boolean)`