类 UrlFilenameViewController
- 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
- org.springframework.web.servlet.mvc.UrlFilenameViewController
- 所有已实现的接口:
Aware
,ApplicationContextAware
,ServletContextAware
,Controller
public class UrlFilenameViewController extends AbstractUrlViewController
SimpleController
implementation that transforms the virtual path of a URL into a view name and returns that view.Can optionally prepend a
prefix
and/or append asuffix
to build the viewname from the URL filename.Find some examples below:
"/index" -> "index"
"/index.html" -> "index"
"/index.html"
+ prefix"pre_"
and suffix"_suf" -> "pre_index_suf"
"/products/view.html" -> "products/view"
Thanks to David Barri for suggesting prefix/suffix support!
- 作者:
- Alef Arendsen, Juergen Hoeller, Rob Harrop
- 另请参阅:
setPrefix(java.lang.String)
,setSuffix(java.lang.String)
字段概要
从类继承的字段 org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
构造器概要
构造器 构造器 说明 UrlFilenameViewController()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
extractOperableUrl(HttpServletRequest request)
Extract a URL path from the given request, suitable for view name extraction.protected String
extractViewNameFromUrlPath(String uri)
Extract the URL filename from the given request URI.protected String
getPrefix()
Return the prefix to prepend to the request URL filename.protected String
getSuffix()
Return the suffix to append to the request URL filename.protected String
getViewNameForRequest(HttpServletRequest request)
Returns view name based on the URL filename, with prefix/suffix applied when appropriate.protected String
getViewNameForUrlPath(String uri)
Returns view name based on the URL filename, with prefix/suffix applied when appropriate.protected String
postProcessViewName(String viewName)
Build the full view name based on the given view name as indicated by the URL path.void
setPrefix(String prefix)
Set the prefix to prepend to the request URL filename to build a view name.void
setSuffix(String suffix)
Set the suffix to append to the request URL filename to build a view name.从类继承的方法 org.springframework.web.servlet.mvc.AbstractUrlViewController
getUrlPathHelper, handleRequestInternal, setAlwaysUseFullPath, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
从类继承的方法 org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
从类继承的方法 org.springframework.web.servlet.support.WebContentGenerator
applyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader, setVaryByRequestHeaders
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
UrlFilenameViewController
public UrlFilenameViewController()
方法详细资料
setPrefix
public void setPrefix(String prefix)
Set the prefix to prepend to the request URL filename to build a view name.
setSuffix
public void setSuffix(String suffix)
Set the suffix to append to the request URL filename to build a view name.
getViewNameForRequest
protected String getViewNameForRequest(HttpServletRequest request)
Returns view name based on the URL filename, with prefix/suffix applied when appropriate.- 指定者:
getViewNameForRequest
在类中AbstractUrlViewController
- 参数:
request
- current HTTP request- 返回:
- a view name for this request (never
null
) - 另请参阅:
extractViewNameFromUrlPath(java.lang.String)
,setPrefix(java.lang.String)
,setSuffix(java.lang.String)
extractOperableUrl
protected String extractOperableUrl(HttpServletRequest request)
Extract a URL path from the given request, suitable for view name extraction.- 参数:
request
- current HTTP request- 返回:
- the URL to use for view name extraction
getViewNameForUrlPath
protected String getViewNameForUrlPath(String uri)
Returns view name based on the URL filename, with prefix/suffix applied when appropriate.- 参数:
uri
- the request URI; for example"/index.html"
- 返回:
- the extracted URI filename; for example
"index"
- 另请参阅:
extractViewNameFromUrlPath(java.lang.String)
,postProcessViewName(java.lang.String)
extractViewNameFromUrlPath
protected String extractViewNameFromUrlPath(String uri)
Extract the URL filename from the given request URI.- 参数:
uri
- the request URI; for example"/index.html"
- 返回:
- the extracted URI filename; for example
"index"
postProcessViewName
protected String postProcessViewName(String viewName)
Build the full view name based on the given view name as indicated by the URL path.The default implementation simply applies prefix and suffix. This can be overridden, for example, to manipulate upper case / lower case, etc.
- 参数:
viewName
- the original view name, as indicated by the URL path- 返回:
- the full view name to use
- 另请参阅:
getPrefix()
,getSuffix()