21
21
import java .util .LinkedHashMap ;
22
22
import java .util .Map ;
23
23
import java .util .Properties ;
24
- import javax .servlet .ServletContext ;
25
24
import javax .servlet .http .HttpServletRequest ;
26
25
27
26
import org .apache .commons .logging .Log ;
34
33
35
34
/**
36
35
* Helper class for URL path matching. Provides support for URL paths in
37
- * RequestDispatcher includes and support for consistent URL decoding.
36
+ * {@code RequestDispatcher} includes and support for consistent URL decoding.
38
37
*
39
38
* <p>Used by {@link org.springframework.web.servlet.handler.AbstractUrlHandlerMapping}
40
39
* and {@link org.springframework.web.servlet.support.RequestContext} for path matching
44
43
* @author Rob Harrop
45
44
* @author Rossen Stoyanchev
46
45
* @since 14.01.2004
46
+ * @see #getLookupPathForRequest
47
+ * @see javax.servlet.RequestDispatcher
47
48
*/
48
49
public class UrlPathHelper {
49
50
@@ -70,8 +71,9 @@ public class UrlPathHelper {
70
71
71
72
72
73
/**
73
- * Whether URL lookups should always use the full path within current
74
- * application context, i.e. within {@link ServletContext#getContextPath()}.
74
+ * Whether URL lookups should always use the full path within the current
75
+ * web application context, i.e. within
76
+ * {@link javax.servlet.ServletContext#getContextPath()}.
75
77
* <p>If set to {@literal false} the path within the current servlet mapping
76
78
* is used instead if applicable (i.e. in the case of a prefix based Servlet
77
79
* mapping such as "/myServlet/*").
@@ -157,8 +159,8 @@ protected String getDefaultEncoding() {
157
159
* <p>Detects include request URL if called within a RequestDispatcher include.
158
160
* @param request current HTTP request
159
161
* @return the lookup path
160
- * @see #getPathWithinApplication
161
162
* @see #getPathWithinServletMapping
163
+ * @see #getPathWithinApplication
162
164
*/
163
165
public String getLookupPathForRequest (HttpServletRequest request ) {
164
166
// Always use full path within current servlet context?
@@ -207,6 +209,7 @@ public String getLookupPathForRequest(HttpServletRequest request, @Nullable Stri
207
209
* <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
208
210
* @param request current HTTP request
209
211
* @return the path within the servlet mapping, or ""
212
+ * @see #getLookupPathForRequest
210
213
*/
211
214
public String getPathWithinServletMapping (HttpServletRequest request ) {
212
215
String pathWithinApp = getPathWithinApplication (request );
@@ -254,6 +257,7 @@ public String getPathWithinServletMapping(HttpServletRequest request) {
254
257
* <p>Detects include request URL if called within a RequestDispatcher include.
255
258
* @param request current HTTP request
256
259
* @return the path within the web application
260
+ * @see #getLookupPathForRequest
257
261
*/
258
262
public String getPathWithinApplication (HttpServletRequest request ) {
259
263
String contextPath = getContextPath (request );
@@ -308,7 +312,7 @@ else if (index1 == requestUri.length()) {
308
312
/**
309
313
* Sanitize the given path. Uses the following rules:
310
314
* <ul>
311
- * <li>replace all "//" by "/"</li>
315
+ * <li>replace all "//" by "/"</li>
312
316
* </ul>
313
317
*/
314
318
private String getSanitizedPath (final String path ) {
@@ -512,8 +516,8 @@ protected String determineEncoding(HttpServletRequest request) {
512
516
513
517
/**
514
518
* Remove ";" (semicolon) content from the given request URI if the
515
- * {@linkplain #setRemoveSemicolonContent(boolean) removeSemicolonContent}
516
- * property is set to "true". Note that "jssessionid " is always removed.
519
+ * {@linkplain #setRemoveSemicolonContent removeSemicolonContent}
520
+ * property is set to "true". Note that "jsessionid " is always removed.
517
521
* @param requestUri the request URI string to remove ";" content from
518
522
* @return the updated URI string
519
523
*/
@@ -544,12 +548,10 @@ private String removeJsessionid(String requestUri) {
544
548
}
545
549
546
550
/**
547
- * Decode the given URI path variables via
548
- * {@link #decodeRequestString(HttpServletRequest, String)} unless
549
- * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
550
- * assumed the URL path from which the variables were extracted is already
551
- * decoded through a call to
552
- * {@link #getLookupPathForRequest(HttpServletRequest)}.
551
+ * Decode the given URI path variables via {@link #decodeRequestString} unless
552
+ * {@link #setUrlDecode} is set to {@code true} in which case it is assumed
553
+ * the URL path from which the variables were extracted is already decoded
554
+ * through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
553
555
* @param request current HTTP request
554
556
* @param vars the URI variables extracted from the URL path
555
557
* @return the same Map or a new Map instance
@@ -566,18 +568,16 @@ public Map<String, String> decodePathVariables(HttpServletRequest request, Map<S
566
568
}
567
569
568
570
/**
569
- * Decode the given matrix variables via
570
- * {@link #decodeRequestString(HttpServletRequest, String)} unless
571
- * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
572
- * assumed the URL path from which the variables were extracted is already
573
- * decoded through a call to
574
- * {@link #getLookupPathForRequest(HttpServletRequest)}.
571
+ * Decode the given matrix variables via {@link #decodeRequestString} unless
572
+ * {@link #setUrlDecode} is set to {@code true} in which case it is assumed
573
+ * the URL path from which the variables were extracted is already decoded
574
+ * through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
575
575
* @param request current HTTP request
576
576
* @param vars the URI variables extracted from the URL path
577
577
* @return the same Map or a new Map instance
578
578
*/
579
- public MultiValueMap <String , String > decodeMatrixVariables (HttpServletRequest request ,
580
- MultiValueMap <String , String > vars ) {
579
+ public MultiValueMap <String , String > decodeMatrixVariables (
580
+ HttpServletRequest request , MultiValueMap <String , String > vars ) {
581
581
582
582
if (this .urlDecode ) {
583
583
return vars ;
0 commit comments