RequestToViewNameTranslator that simply transforms the URI of
the incoming request into a view name.
Can be explicitly defined as the viewNameTranslator bean in a
org. context.
Otherwise, a plain default instance will be used.
The default transformation simply strips leading and trailing slashes
as well as the file extension of the URI, and returns the result as the
view name with the configured prefix and a
suffix added as appropriate.
The stripping of the leading slash and file extension can be disabled
using the stripLeadingSlash and
stripExtension properties, respectively.
Find below some examples of request to view name translation.
http://localhost:8080/gamecast/display.html » displayhttp://localhost:8080/gamecast/displayShoppingCart.html » displayShoppingCarthttp://localhost:8080/gamecast/admin/index.html » admin/indexorg.springframework.web.servlet.RequestToViewNameTranslator , org.springframework.web.servlet.ViewResolver
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private String | |
| private static final String | |
| private boolean | |
| private boolean | |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | getViewName(HttpServletRequest
the incoming request)HttpServletRequest providing
the context from which a view name is to be resolvedImplements org. Translates the request URI of the incoming |
| public void | |
| public void | setSeparator(String separator)
Set the value that will replace ' |
| public void | setStripExtension(boolean stripExtension)
Set whether file extensions should be stripped from the URI when generating the view name. |
| public void | setStripLeadingSlash(boolean stripLeadingSlash)
Set whether leading slashes should be stripped from the URI when generating the view name. |
| public void | setStripTrailingSlash(boolean stripTrailingSlash)
Set whether trailing slashes should be stripped from the URI when generating the view name. |
| public void | |
| protected String | Returns: the transformed path, with slashes and extensions stripped if desiredthe lookup path for the current request,
as determined by the UrlPathHelper lookupPath)Transform the request URI (in the context of the webapp) stripping slashes and extensions, and replacing the separator as required. |
| prefix | back to summary |
|---|---|
| private String prefix | |
| separator | back to summary |
|---|---|
| private String separator | |
| SLASH | back to summary |
|---|---|
| private static final String SLASH | |
| stripExtension | back to summary |
|---|---|
| private boolean stripExtension | |
| stripLeadingSlash | back to summary |
|---|---|
| private boolean stripLeadingSlash | |
| stripTrailingSlash | back to summary |
|---|---|
| private boolean stripTrailingSlash | |
| suffix | back to summary |
|---|---|
| private String suffix | |
| DefaultRequestToViewNameTranslator | back to summary |
|---|---|
| public DefaultRequestToViewNameTranslator() | |
| getViewName | back to summary |
|---|---|
| public String getViewName(HttpServletRequest request) Implements org. Translates the request URI of the incoming
| |
| setPrefix | back to summary |
|---|---|
| public void setPrefix(String prefix) Set the prefix to prepend to generated view names.
| |
| setSeparator | back to summary |
|---|---|
| public void setSeparator(String separator) Set the value that will replace ' | |
| setStripExtension | back to summary |
|---|---|
| public void setStripExtension(boolean stripExtension) Set whether file extensions should be stripped from the URI when generating the view name. Default is "true". | |
| setStripLeadingSlash | back to summary |
|---|---|
| public void setStripLeadingSlash(boolean stripLeadingSlash) Set whether leading slashes should be stripped from the URI when generating the view name. Default is "true". | |
| setStripTrailingSlash | back to summary |
|---|---|
| public void setStripTrailingSlash(boolean stripTrailingSlash) Set whether trailing slashes should be stripped from the URI when generating the view name. Default is "true". | |
| setSuffix | back to summary |
|---|---|
| public void setSuffix(String suffix) Set the suffix to append to generated view names.
| |
| transformPath | back to summary |
|---|---|
| protected String transformPath(String lookupPath) Transform the request URI (in the context of the webapp) stripping slashes and extensions, and replacing the separator as required. | |