|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.util.UrlPathHelper
public class UrlPathHelper
Helper class for URL path matching. Provides support for URL paths in RequestDispatcher includes and support for consistent URL decoding.
Used by AbstractUrlHandlerMapping, AbstractUrlMethodNameResolver and RequestContext for path matching and/or URI determination.
AbstractUrlHandlerMapping
,
AbstractUrlMethodNameResolver
,
RequestContext
Field Summary | |
---|---|
static String |
INCLUDE_CONTEXT_PATH_REQUEST_ATTRIBUTE
Deprecated. as of Spring 2.0, in favor of WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE |
static String |
INCLUDE_SERVLET_PATH_REQUEST_ATTRIBUTE
Deprecated. as of Spring 2.0, in favor of WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE |
static String |
INCLUDE_URI_REQUEST_ATTRIBUTE
Deprecated. as of Spring 2.0, in favor of WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE |
Constructor Summary | |
---|---|
UrlPathHelper()
|
Method Summary | |
---|---|
String |
decodeRequestString(HttpServletRequest request,
String source)
Decode the given source string with a URLDecoder. |
protected String |
determineEncoding(HttpServletRequest request)
Determine the encoding for the given request. |
String |
getContextPath(HttpServletRequest request)
Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. |
protected String |
getDefaultEncoding()
Return the default character encoding to use for URL decoding. |
String |
getLookupPathForRequest(HttpServletRequest request)
Return the mapping lookup path for the given request, within the current servlet mapping if applicable, else within the web application. |
String |
getOriginatingContextPath(HttpServletRequest request)
Return the context path for the given request, detecting an include request URL if called within a RequestDispatcher include. |
String |
getOriginatingQueryString(HttpServletRequest request)
Return the request URI for root of the given request. |
String |
getOriginatingRequestUri(HttpServletRequest request)
Return the request URI for root of the given request. |
String |
getPathWithinApplication(HttpServletRequest request)
Return the path within the web application for the given request. |
String |
getPathWithinServletMapping(HttpServletRequest request)
Return the path within the servlet mapping for the given request, i.e. the part of the request's URL beyond the part that called the servlet, or "" if the whole URL has been used to identify the servlet. |
String |
getRequestUri(HttpServletRequest request)
Return the request URI for the given request, detecting an include request URL if called within a RequestDispatcher include. |
String |
getServletPath(HttpServletRequest request)
Return the servlet path for the given request, regarding an include request URL if called within a RequestDispatcher include. |
void |
setAlwaysUseFullPath(boolean alwaysUseFullPath)
Set if URL lookup should always use full path within current servlet context. |
void |
setDefaultEncoding(String defaultEncoding)
Set the default character encoding to use for URL decoding. |
void |
setUrlDecode(boolean urlDecode)
Set if context path and request URI should be URL-decoded. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String INCLUDE_URI_REQUEST_ATTRIBUTE
WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE
public static final String INCLUDE_CONTEXT_PATH_REQUEST_ATTRIBUTE
WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE
public static final String INCLUDE_SERVLET_PATH_REQUEST_ATTRIBUTE
WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE
Constructor Detail |
---|
public UrlPathHelper()
Method Detail |
---|
public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
public void setUrlDecode(boolean urlDecode)
Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).
Note: Setting this to "true" requires JDK 1.4 if the encoding differs from the VM's platform default encoding, as JDK 1.3's URLDecoder class does not offer a way to specify the encoding.
getServletPath(javax.servlet.http.HttpServletRequest)
,
getContextPath(javax.servlet.http.HttpServletRequest)
,
getRequestUri(javax.servlet.http.HttpServletRequest)
,
WebUtils.DEFAULT_CHARACTER_ENCODING
,
ServletRequest.getCharacterEncoding()
,
URLDecoder.decode(String, String)
,
URLDecoder.decode(String)
public void setDefaultEncoding(String defaultEncoding)
If the request specifies a character encoding itself, the request encoding will override this setting. This also allows for generically overriding the character encoding in a filter that invokes the ServletRequest.setCharacterEncoding method.
defaultEncoding
- the character encoding to usedetermineEncoding(javax.servlet.http.HttpServletRequest)
,
ServletRequest.getCharacterEncoding()
,
ServletRequest.setCharacterEncoding(java.lang.String)
,
WebUtils.DEFAULT_CHARACTER_ENCODING
protected String getDefaultEncoding()
public String getLookupPathForRequest(HttpServletRequest request)
Regards include request URL if called within a RequestDispatcher include.
request
- current HTTP request
getPathWithinApplication(javax.servlet.http.HttpServletRequest)
,
getPathWithinServletMapping(javax.servlet.http.HttpServletRequest)
public String getPathWithinServletMapping(HttpServletRequest request)
Regards include request URL if called within a RequestDispatcher include.
E.g.: servlet mapping = "/test/*"; request URI = "/test/a" -> "/a".
E.g.: servlet mapping = "/test"; request URI = "/test" -> "".
E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
request
- current HTTP request
public String getPathWithinApplication(HttpServletRequest request)
Regards include request URL if called within a RequestDispatcher include.
request
- current HTTP request
public String getRequestUri(HttpServletRequest request)
As the value returned by request.getRequestURI()
is not
decoded by the servlet container, this method will decode it.
The URI that the web container resolves should be correct, but some containers like JBoss/Jetty incorrectly include ";" strings like ";jsessionid" in the URI. This method cuts off such incorrect appendices.
request
- current HTTP request
public String getContextPath(HttpServletRequest request)
As the value returned by request.getContextPath()
is not
decoded by the servlet container, this method will decode it.
request
- current HTTP request
public String getServletPath(HttpServletRequest request)
As the value returned by request.getServletPath() is already decoded by the servlet container, this method will not attempt to decode it.
request
- current HTTP request
public String getOriginatingRequestUri(HttpServletRequest request)
public String getOriginatingContextPath(HttpServletRequest request)
As the value returned by request.getContextPath()
is not
decoded by the servlet container, this method will decode it.
request
- current HTTP request
public String getOriginatingQueryString(HttpServletRequest request)
public String decodeRequestString(HttpServletRequest request, String source)
Default implementation uses URLDecoder.decode(input, enc)
on JDK 1.4+, falling back to URLDecoder.decode(input)
(which uses the platform default encoding) on JDK 1.3.
request
- current HTTP requestsource
- the String to decode
WebUtils.DEFAULT_CHARACTER_ENCODING
,
ServletRequest.getCharacterEncoding()
,
URLDecoder.decode(String, String)
,
URLDecoder.decode(String)
protected String determineEncoding(HttpServletRequest request)
The default implementation checks the request encoding, falling back to the default encoding specified for this resolver.
request
- current HTTP request
null
)ServletRequest.getCharacterEncoding()
,
setDefaultEncoding(java.lang.String)
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |