Skip to content

Commit ec03e88

Browse files
committed
Remove path variables from pathWithinMapping
Closes gh-27913
1 parent 11cb938 commit ec03e88

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
2828

2929
import org.springframework.beans.BeansException;
3030
import org.springframework.context.ApplicationContext;
31-
import org.springframework.http.server.PathContainer;
3231
import org.springframework.http.server.RequestPath;
3332
import org.springframework.lang.Nullable;
3433
import org.springframework.util.AntPathMatcher;
@@ -216,8 +215,9 @@ protected Object lookupHandler(
216215
handler = obtainApplicationContext().getBean(handlerName);
217216
}
218217
validateHandler(handler, request);
219-
PathContainer pathWithinMapping = pattern.extractPathWithinPattern(path.pathWithinApplication());
220-
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping.value(), null);
218+
String pathWithinMapping = pattern.extractPathWithinPattern(path.pathWithinApplication()).value();
219+
pathWithinMapping = UrlPathHelper.defaultInstance.removeSemicolonContent(pathWithinMapping);
220+
return buildPathExposingHandler(handler, pattern.getPatternString(), pathWithinMapping, null);
221221
}
222222

223223
/**

spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -102,7 +102,7 @@ void checkMappings(String beanName) throws Exception {
102102
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("/welcome.html");
103103
assertThat(request.getAttribute(BEST_MATCHING_HANDLER_ATTRIBUTE)).isEqualTo(bean);
104104

105-
request = PathPatternsTestUtils.initRequest("GET", "/welcome.x", usePathPatterns);
105+
request = PathPatternsTestUtils.initRequest("GET", "/welcome.x;jsessionid=123", usePathPatterns);
106106
chain = getHandler(hm, request);
107107
assertThat(chain.getHandler()).isSameAs(otherBean);
108108
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("welcome.x");

0 commit comments

Comments
 (0)