public class UrlFilenameViewController extends AbstractUrlViewController
Controller
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 a
suffix
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!
setPrefix(java.lang.String)
,
setSuffix(java.lang.String)
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST
logger
Constructor and Description |
---|
UrlFilenameViewController() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
extractOperableUrl(HttpServletRequest request)
Extract a URL path from the given request,
suitable for view name extraction.
|
protected java.lang.String |
extractViewNameFromUrlPath(java.lang.String uri)
Extract the URL filename from the given request URI.
|
protected java.lang.String |
getPrefix()
Return the prefix to prepend to the request URL filename.
|
protected java.lang.String |
getSuffix()
Return the suffix to append to the request URL filename.
|
protected java.lang.String |
getViewNameForRequest(HttpServletRequest request)
Returns view name based on the URL filename,
with prefix/suffix applied when appropriate.
|
protected java.lang.String |
getViewNameForUrlPath(java.lang.String uri)
Returns view name based on the URL filename,
with prefix/suffix applied when appropriate.
|
protected java.lang.String |
postProcessViewName(java.lang.String viewName)
Build the full view name based on the given view name
as indicated by the URL path.
|
void |
setPrefix(java.lang.String prefix)
Set the prefix to prepend to the request URL filename
to build a view name.
|
void |
setSuffix(java.lang.String suffix)
Set the suffix to append to the request URL filename
to build a view name.
|
getUrlPathHelper, handleRequestInternal, setAlwaysUseFullPath, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
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
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public void setPrefix(java.lang.String prefix)
protected java.lang.String getPrefix()
public void setSuffix(java.lang.String suffix)
protected java.lang.String getSuffix()
protected java.lang.String getViewNameForRequest(HttpServletRequest request)
getViewNameForRequest
in class AbstractUrlViewController
request
- current HTTP requestnull
)extractViewNameFromUrlPath(java.lang.String)
,
setPrefix(java.lang.String)
,
setSuffix(java.lang.String)
protected java.lang.String extractOperableUrl(HttpServletRequest request)
request
- current HTTP requestprotected java.lang.String getViewNameForUrlPath(java.lang.String uri)
uri
- the request URI; for example "/index.html"
"index"
extractViewNameFromUrlPath(java.lang.String)
,
postProcessViewName(java.lang.String)
protected java.lang.String extractViewNameFromUrlPath(java.lang.String uri)
uri
- the request URI; for example "/index.html"
"index"
protected java.lang.String postProcessViewName(java.lang.String viewName)
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 pathgetPrefix()
,
getSuffix()