1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
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/*").
@@ -90,7 +92,7 @@ public void setAlwaysUseFullPath(boolean alwaysUseFullPath) {
90
92
* <p>By default this is set to {@literal true}.
91
93
* <p><strong>Note:</strong> Be aware the servlet path will not match when
92
94
* compared to encoded paths. Therefore use of {@code urlDecode=false} is
93
- * not compatible with a prefix-based Servlet mappping and likewise implies
95
+ * not compatible with a prefix-based Servlet mapping and likewise implies
94
96
* also setting {@code alwaysUseFullPath=true}.
95
97
* @see #getServletPath
96
98
* @see #getContextPath
@@ -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?
@@ -187,6 +189,7 @@ public String getLookupPathForRequest(HttpServletRequest request) {
187
189
* <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
188
190
* @param request current HTTP request
189
191
* @return the path within the servlet mapping, or ""
192
+ * @see #getLookupPathForRequest
190
193
*/
191
194
public String getPathWithinServletMapping (HttpServletRequest request ) {
192
195
String pathWithinApp = getPathWithinApplication (request );
@@ -234,6 +237,7 @@ public String getPathWithinServletMapping(HttpServletRequest request) {
234
237
* <p>Detects include request URL if called within a RequestDispatcher include.
235
238
* @param request current HTTP request
236
239
* @return the path within the web application
240
+ * @see #getLookupPathForRequest
237
241
*/
238
242
public String getPathWithinApplication (HttpServletRequest request ) {
239
243
String contextPath = getContextPath (request );
@@ -288,7 +292,7 @@ else if (index1 == requestUri.length()) {
288
292
/**
289
293
* Sanitize the given path. Uses the following rules:
290
294
* <ul>
291
- * <li>replace all "//" by "/"</li>
295
+ * <li>replace all "//" by "/"</li>
292
296
* </ul>
293
297
*/
294
298
private String getSanitizedPath (final String path ) {
@@ -492,8 +496,8 @@ protected String determineEncoding(HttpServletRequest request) {
492
496
493
497
/**
494
498
* Remove ";" (semicolon) content from the given request URI if the
495
- * {@linkplain #setRemoveSemicolonContent(boolean) removeSemicolonContent}
496
- * property is set to "true". Note that "jssessionid " is always removed.
499
+ * {@linkplain #setRemoveSemicolonContent removeSemicolonContent}
500
+ * property is set to "true". Note that "jsessionid " is always removed.
497
501
* @param requestUri the request URI string to remove ";" content from
498
502
* @return the updated URI string
499
503
*/
@@ -524,12 +528,10 @@ private String removeJsessionid(String requestUri) {
524
528
}
525
529
526
530
/**
527
- * Decode the given URI path variables via
528
- * {@link #decodeRequestString(HttpServletRequest, String)} unless
529
- * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
530
- * assumed the URL path from which the variables were extracted is already
531
- * decoded through a call to
532
- * {@link #getLookupPathForRequest(HttpServletRequest)}.
531
+ * Decode the given URI path variables via {@link #decodeRequestString} unless
532
+ * {@link #setUrlDecode} is set to {@code true} in which case it is assumed
533
+ * the URL path from which the variables were extracted is already decoded
534
+ * through a call to {@link #getLookupPathForRequest(HttpServletRequest)}.
533
535
* @param request current HTTP request
534
536
* @param vars the URI variables extracted from the URL path
535
537
* @return the same Map or a new Map instance
@@ -546,18 +548,16 @@ public Map<String, String> decodePathVariables(HttpServletRequest request, Map<S
546
548
}
547
549
548
550
/**
549
- * Decode the given matrix variables via
550
- * {@link #decodeRequestString(HttpServletRequest, String)} unless
551
- * {@link #setUrlDecode(boolean)} is set to {@code true} in which case it is
552
- * assumed the URL path from which the variables were extracted is already
553
- * decoded through a call to
554
- * {@link #getLookupPathForRequest(HttpServletRequest)}.
551
+ * Decode the given matrix 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)}.
555
555
* @param request current HTTP request
556
556
* @param vars the URI variables extracted from the URL path
557
557
* @return the same Map or a new Map instance
558
558
*/
559
- public MultiValueMap <String , String > decodeMatrixVariables (HttpServletRequest request ,
560
- MultiValueMap <String , String > vars ) {
559
+ public MultiValueMap <String , String > decodeMatrixVariables (
560
+ HttpServletRequest request , MultiValueMap <String , String > vars ) {
561
561
562
562
if (this .urlDecode ) {
563
563
return vars ;
0 commit comments