Fix issue with extracting matrix variables
The servlet spec recommends removing path parameters from the contextPath, servletPath, and pathInfo but not from the requestURI. This poses a challenge for the UrlPathHelper, which determines the lookup path by comparing the above. This change introduces a method that matches the requestURI to the contextPath and servletPath ignoring path parameters (i.e. matrix variables) for comparison purposes while also preserving them in the resulting lookup path.
This commit is contained in:
@@ -69,6 +69,15 @@ public class UrlPathHelperTests {
|
||||
assertEquals("Incorrect path returned", "/welcome.html", helper.getPathWithinApplication(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathWithinServlet() {
|
||||
request.setContextPath("/petclinic");
|
||||
request.setServletPath("/main");
|
||||
request.setRequestURI("/petclinic/main/welcome.html");
|
||||
|
||||
assertEquals("Incorrect path returned", "/welcome.html", helper.getPathWithinServletMapping(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestUri() {
|
||||
request.setRequestURI("/welcome.html");
|
||||
@@ -104,6 +113,29 @@ public class UrlPathHelperTests {
|
||||
assertEquals("jsessionid should always be removed", "/foo;a=b;c=d", helper.getRequestUri(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLookupPathWithSemicolonContent() {
|
||||
helper.setRemoveSemicolonContent(false);
|
||||
|
||||
request.setContextPath("/petclinic");
|
||||
request.setServletPath("/main");
|
||||
request.setRequestURI("/petclinic;a=b/main;b=c/welcome.html;c=d");
|
||||
|
||||
assertEquals("/welcome.html;c=d", helper.getLookupPathForRequest(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLookupPathWithSemicolonContentAndNullPathInfo() {
|
||||
helper.setRemoveSemicolonContent(false);
|
||||
|
||||
request.setContextPath("/petclinic");
|
||||
request.setServletPath("/welcome.html");
|
||||
request.setRequestURI("/petclinic;a=b/welcome.html;c=d");
|
||||
|
||||
assertEquals("/welcome.html;c=d", helper.getLookupPathForRequest(request));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// suite of tests root requests for default servlets (SRV 11.2) on Websphere vs Tomcat and other containers
|
||||
// see: http://jira.springframework.org/browse/SPR-7064
|
||||
|
||||
Reference in New Issue
Block a user