Class PrefixingPathContext
java.lang.Object
com.foreach.across.modules.web.context.PrefixingPathContext
- All Implemented Interfaces:
WebAppPathResolver
- Direct Known Subclasses:
WebJarsPathContext
Helper class for relative urls that need a prefix. Any path passed to this instance will be prefixed
unless an exception is defined. Possible exceptions are:
Optionally an additional map of named prefixers can be added
- path starts with !: only exclamation mark will be removed, no prefixing will be done (supress prefixing)
- path starts with ~: will not be modified
- path contains ://: considered absolute url - will not be modified
- path starts with @prefixer:: will be re-routed to the prefixer with that name if present
Optionally an additional map of named prefixers can be added
setNamedPrefixMap(java.util.Map)
. Urls containing
one of these names in the correct format (eg: @somePrefixer:/myPath) will be prefixed by that prefixer
instead of the current one.- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
applyPrefixToPath
(String prefix, String path) getRoot()
Resolves the requested path in the relative context of the web application.Creates a Spring MVC redirect for the requested path.void
setNamedPrefixMap
(@NonNull Map<String, PrefixingPathContext> namedPrefixers) Sets a collection of prefixing contexts with a name.
-
Field Details
-
SUPPRESS
- See Also:
-
-
Constructor Details
-
PrefixingPathContext
-
-
Method Details
-
setNamedPrefixMap
Sets a collection of prefixing contexts with a name. Any paths starting with {NAME} will find re-routed to the named prefixer instead of handled by the current prefixing context.- Parameters:
namedPrefixers
- Map of namedPrefixers, should not be null.
-
getRoot
- Returns:
- Root of the prefixed context (no sub path).
-
getPathPrefix
-
path
Description copied from interface:WebAppPathResolver
Resolves the requested path in the relative context of the web application. Note that this does not take the actual web application context of the container into account.- Specified by:
path
in interfaceWebAppPathResolver
- Parameters:
path
- Original path to be resolved.- Returns:
- Resolved path - might be modified.
-
redirect
Description copied from interface:WebAppPathResolver
Creates a Spring MVC redirect for the requested path. This will usually apply the regular path resolving and prepend redirect: if necessary.- Specified by:
redirect
in interfaceWebAppPathResolver
- Parameters:
path
- Original path for which to create a redirect.- Returns:
- Redirect path.
-
applyPrefixToPath
-