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 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.
|
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(String prefix)
protected String getPrefix()
public void setSuffix(String suffix)
protected String getSuffix()
protected 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 String extractOperableUrl(HttpServletRequest request)
request
- current HTTP requestprotected String getViewNameForUrlPath(String uri)
uri
- the request URI; for example "/index.html"
"index"
extractViewNameFromUrlPath(java.lang.String)
,
postProcessViewName(java.lang.String)
protected String extractViewNameFromUrlPath(String uri)
uri
- the request URI; for example "/index.html"
"index"
protected String postProcessViewName(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()