Deprecate and set trailingSlash option to false

Closes gh-28552
This commit is contained in:
rstoyanchev
2022-06-29 16:08:37 +01:00
parent d2e27ad754
commit b312eca391
27 changed files with 84 additions and 82 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -358,7 +358,10 @@ public interface MockMvcWebTestClient {
* Whether to match trailing slashes.
* <p>This is delegated to
* {@link StandaloneMockMvcBuilder#setUseTrailingSlashPatternMatch(boolean)}.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
ControllerSpec useTrailingSlashPatternMatch(boolean useTrailingSlashPatternMatch);
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -152,6 +152,7 @@ class StandaloneMockMvcSpec extends AbstractMockMvcServerSpec<MockMvcWebTestClie
return this;
}
@SuppressWarnings("deprecation")
@Override
public StandaloneMockMvcSpec useTrailingSlashPatternMatch(boolean useTrailingSlashPatternMatch) {
this.mockMvcBuilder.setUseTrailingSlashPatternMatch(useTrailingSlashPatternMatch);

View File

@@ -343,8 +343,10 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
/**
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a method mapped to "/users" also matches to "/users/".
* <p>The default value is {@code true}.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public StandaloneMockMvcBuilder setUseTrailingSlashPatternMatch(boolean useTrailingSlashPatternMatch) {
this.useTrailingSlashPatternMatch = useTrailingSlashPatternMatch;
return this;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class FormContentTests {
@RestController
private static class Spr15753Controller {
@PutMapping
@PutMapping("/")
public String test(Data d) {
return String.format("d1:%s, d2:%s.", d.getD1(), d.getD2());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -150,6 +150,7 @@ public class PathPattern implements Comparable<PathPattern> {
private boolean catchAll = false;
@SuppressWarnings("deprecation")
PathPattern(String patternText, PathPatternParser parser, @Nullable PathElement head) {
this.patternString = patternText;
this.parser = parser;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.http.server.PathContainer;
*/
public class PathPatternParser {
private boolean matchOptionalTrailingSeparator = true;
private boolean matchOptionalTrailingSeparator = false;
private boolean caseSensitive = true;
@@ -48,15 +48,22 @@ public class PathPatternParser {
* will also match request paths with a trailing slash. If set to
* {@code false} a {@code PathPattern} will only match request paths with
* a trailing slash.
* <p>The default is {@code true}.
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
* order to support the deprecation of the property.
* @deprecated transparent support for trailing slashes is deprecated as of
* 6.0 in favor of configuring explicit redirects through a proxy,
* Servlet/web filter, or a controller.
*/
@Deprecated
public void setMatchOptionalTrailingSeparator(boolean matchOptionalTrailingSeparator) {
this.matchOptionalTrailingSeparator = matchOptionalTrailingSeparator;
}
/**
* Whether optional trailing slashing match is enabled.
* @deprecated as of 6.0 together with {@link #setMatchOptionalTrailingSeparator(boolean)}.
*/
@Deprecated
public boolean isMatchOptionalTrailingSeparator() {
return this.matchOptionalTrailingSeparator;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +48,6 @@ public class PathPatternRouteMatcher implements RouteMatcher {
public PathPatternRouteMatcher() {
this.parser = new PathPatternParser();
this.parser.setPathOptions(PathContainer.Options.MESSAGE_ROUTE);
this.parser.setMatchOptionalTrailingSeparator(false);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,6 +99,7 @@ public class PathPatternTests {
assertThat(pp.matches(toPathContainer(path))).isFalse();
}
@SuppressWarnings("deprecation")
@Test
public void optionalTrailingSeparators() {
PathPattern pp;
@@ -438,6 +439,7 @@ public class PathPatternTests {
checkCapture("///{foo}///bar", "///one///bar", "foo", "one");
}
@SuppressWarnings("deprecation")
@Test
public void wildcards() {
checkMatches("/*/bar", "/foo/bar");
@@ -725,6 +727,7 @@ public class PathPatternTests {
}
@Test
@SuppressWarnings("deprecation")
public void extractUriTemplateVariables_spr15264() {
PathPattern pp;
pp = new PathPatternParser().parse("/{foo}");
@@ -1145,6 +1148,7 @@ public class PathPatternTests {
return parse(pattern).matchAndExtract(PathPatternTests.toPathContainer(path));
}
@SuppressWarnings("deprecation")
private PathPattern parse(String path) {
PathPatternParser pp = new PathPatternParser();
pp.setMatchOptionalTrailingSeparator(true);
@@ -1158,6 +1162,7 @@ public class PathPatternTests {
return PathContainer.parsePath(path);
}
@SuppressWarnings("deprecation")
private void checkMatches(String uriTemplate, String path) {
PathPatternParser parser = new PathPatternParser();
parser.setMatchOptionalTrailingSeparator(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.util.Map;
import java.util.function.Predicate;
import org.springframework.lang.Nullable;
import org.springframework.web.util.pattern.PathPatternParser;
/**
* Assist with configuring {@code HandlerMapping}'s with path matching options.
@@ -55,8 +56,12 @@ public class PathMatchConfigurer {
/**
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a method mapped to "/users" also matches to "/users/".
* <p>The default value is {@code true}.
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
* order to support the deprecation of the property.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) {
this.trailingSlashMatch = trailingSlashMatch;
return this;
@@ -83,6 +88,7 @@ public class PathMatchConfigurer {
@Nullable
@Deprecated
protected Boolean isUseTrailingSlashMatch() {
return this.trailingSlashMatch;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -142,6 +142,7 @@ public class WebFluxConfigurationSupport implements ApplicationContextAware {
return mapping;
}
@SuppressWarnings("deprecation")
private void configureAbstractHandlerMapping(AbstractHandlerMapping mapping, PathMatchConfigurer configurer) {
mapping.setCorsConfigurations(getCorsConfigurations());
Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport
LogDelegateFactory.getHiddenLog(HandlerMapping.class.getName() + ".Mappings");
private final PathPatternParser patternParser;
private final PathPatternParser patternParser = new PathPatternParser();
@Nullable
private CorsConfigurationSource corsConfigurationSource;
@@ -71,11 +71,6 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport
private String beanName;
public AbstractHandlerMapping() {
this.patternParser = new PathPatternParser();
}
/**
* Shortcut method for setting the same property on the underlying pattern
* parser in use. For more details see:
@@ -98,7 +93,12 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport
* <li>{@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)} --
* the trailing slash option, including its default value.
* </ul>
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
* order to support the deprecation of the property.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public void setUseTrailingSlashMatch(boolean trailingSlashMatch) {
this.patternParser.setMatchOptionalTrailingSeparator(trailingSlashMatch);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -110,7 +110,7 @@ public class WebFluxConfigurationSupportTests {
PathPatternParser patternParser = mapping.getPathPatternParser();
assertThat(patternParser).isNotNull();
boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser);
assertThat(matchOptionalTrailingSlash).isTrue();
assertThat(matchOptionalTrailingSlash).isFalse();
name = "webFluxContentTypeResolver";
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
@@ -124,18 +124,11 @@ public class WebFluxConfigurationSupportTests {
@Test
public void customPathMatchConfig() {
ApplicationContext context = loadConfig(CustomPatchMatchConfig.class);
final Field field = ReflectionUtils.findField(PathPatternParser.class, "matchOptionalTrailingSeparator");
ReflectionUtils.makeAccessible(field);
String name = "requestMappingHandlerMapping";
RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class);
assertThat(mapping).isNotNull();
PathPatternParser patternParser = mapping.getPathPatternParser();
assertThat(patternParser).isNotNull();
boolean matchOptionalTrailingSlash = (boolean) ReflectionUtils.getField(field, patternParser);
assertThat(matchOptionalTrailingSlash).isFalse();
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
assertThat(map.size()).isEqualTo(1);
assertThat(map.keySet().iterator().next().getPatternsCondition().getPatterns())
@@ -323,7 +316,6 @@ public class WebFluxConfigurationSupportTests {
@Override
public void configurePathMatching(PathMatchConfigurer configurer) {
configurer.setUseTrailingSlashMatch(false);
configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,7 +56,6 @@ public class SimpleUrlHandlerMappingTests {
testUrl("/welcome.html", mainController, handlerMapping, "");
testUrl("/welcome.x", otherController, handlerMapping, "welcome.x");
testUrl("/welcome/", otherController, handlerMapping, "welcome");
testUrl("/show.html", mainController, handlerMapping, "");
testUrl("/bookseats.html", mainController, handlerMapping, "");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -107,10 +107,14 @@ public class PatternsRequestConditionTests {
}
@Test
@SuppressWarnings("deprecation")
public void matchTrailingSlash() {
MockServerWebExchange exchange = MockServerWebExchange.from(get("/foo/"));
PatternsRequestCondition condition = createPatternsCondition("/foo");
PathPatternParser patternParser = new PathPatternParser();
patternParser.setMatchOptionalTrailingSeparator(true);
PatternsRequestCondition condition = new PatternsRequestCondition(patternParser.parse("/foo"));
PatternsRequestCondition match = condition.getMatchingCondition(exchange);
assertThat(match).isNotNull();
@@ -118,7 +122,7 @@ public class PatternsRequestConditionTests {
.as("Should match by default")
.isEqualTo("/foo");
condition = createPatternsCondition("/foo");
condition = new PatternsRequestCondition(patternParser.parse("/foo"));
match = condition.getMatchingCondition(exchange);
assertThat(match).isNotNull();

View File

@@ -119,10 +119,6 @@ public class RequestMappingInfoHandlerMappingTests {
ServerWebExchange exchange = MockServerWebExchange.from(get(""));
HandlerMethod hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
assertThat(hm.getMethod()).isEqualTo(expected);
exchange = MockServerWebExchange.from(get("/"));
hm = (HandlerMethod) this.handlerMapping.getHandler(exchange).block();
assertThat(hm.getMethod()).isEqualTo(expected);
}
@Test
@@ -157,7 +153,6 @@ public class RequestMappingInfoHandlerMappingTests {
@Test // SPR-8462
public void getHandlerMediaTypeNotSupported() {
testHttpMediaTypeNotSupportedException("/person/1");
testHttpMediaTypeNotSupportedException("/person/1/");
testHttpMediaTypeNotSupportedException("/person/1.json");
}
@@ -175,7 +170,6 @@ public class RequestMappingInfoHandlerMappingTests {
@Test // SPR-8462
public void getHandlerTestMediaTypeNotAcceptable() {
testMediaTypeNotAcceptable("/persons");
testMediaTypeNotAcceptable("/persons/");
}
@Test // SPR-12854

View File

@@ -106,8 +106,12 @@ public class PathMatchConfigurer {
/**
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a method mapped to "/users" also matches to "/users/".
* <p>The default value is {@code true}.
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
* order to support the deprecation of the property.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) {
this.trailingSlashMatch = trailingSlashMatch;
return this;

View File

@@ -104,7 +104,10 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping i
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a URL pattern such as "/users" also matches to "/users/".
* <p>The default value is {@code false}.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public void setUseTrailingSlashMatch(boolean useTrailingSlashMatch) {
this.useTrailingSlashMatch = useTrailingSlashMatch;
if (getPatternParser() != null) {

View File

@@ -140,8 +140,12 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
/**
* Whether to match to URLs irrespective of the presence of a trailing slash.
* If enabled a method mapped to "/users" also matches to "/users/".
* <p>The default value is {@code true}.
* <p>The default was changed in 6.0 from {@code true} to {@code false} in
* order to support the deprecation of the property.
* @deprecated as of 6.0, see
* {@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)}
*/
@Deprecated
public void setUseTrailingSlashMatch(boolean useTrailingSlashMatch) {
this.useTrailingSlashMatch = useTrailingSlashMatch;
if (getPatternParser() != null) {

View File

@@ -52,7 +52,9 @@
<xsd:documentation><![CDATA[
Whether to match to URLs irrespective of the presence of a trailing slash.
If enabled a method mapped to "/users" also matches to "/users/".
The default value is true.
The default was changed in 6.0 from true to false in order to support the
deprecation of the property.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>

View File

@@ -117,11 +117,6 @@ public class SimpleUrlHandlerMappingTests {
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("welcome.x");
assertThat(request.getAttribute(BEST_MATCHING_HANDLER_ATTRIBUTE)).isEqualTo(otherBean);
request = PathPatternsTestUtils.initRequest("GET", "/welcome/", usePathPatterns);
chain = getHandler(hm, request);
assertThat(chain.getHandler()).isSameAs(otherBean);
assertThat(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).isEqualTo("welcome");
request = PathPatternsTestUtils.initRequest("GET", "/", usePathPatterns);
request.setServletPath("/welcome.html");
chain = getHandler(hm, request);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -127,10 +127,14 @@ public class PathPatternsRequestConditionTests {
}
@Test
@SuppressWarnings("deprecation")
void matchTrailingSlash() {
MockHttpServletRequest request = createRequest("/foo/");
PathPatternsRequestCondition condition = createCondition("/foo");
PathPatternParser patternParser = new PathPatternParser();
patternParser.setMatchOptionalTrailingSeparator(true);
PathPatternsRequestCondition condition = new PathPatternsRequestCondition(patternParser, "/foo");
PathPatternsRequestCondition match = condition.getMatchingCondition(request);
assertThat(match).isNotNull();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-202 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -138,11 +138,6 @@ class RequestMappingInfoHandlerMappingTests {
HandlerMethod handlerMethod = getHandler(mapping, request);
assertThat(handlerMethod.getMethod()).isEqualTo(this.emptyMethod.getMethod());
request = new MockHttpServletRequest("GET", "/");
handlerMethod = getHandler(mapping, request);
assertThat(handlerMethod.getMethod()).isEqualTo(this.emptyMethod.getMethod());
}
@PathPatternsParameterizedTest
@@ -174,7 +169,6 @@ class RequestMappingInfoHandlerMappingTests {
@PathPatternsParameterizedTest // SPR-8462
void getHandlerMediaTypeNotSupported(TestRequestMappingInfoHandlerMapping mapping) {
testHttpMediaTypeNotSupportedException(mapping, "/person/1");
testHttpMediaTypeNotSupportedException(mapping, "/person/1/");
testHttpMediaTypeNotSupportedException(mapping, "/person/1.json");
}
@@ -199,7 +193,6 @@ class RequestMappingInfoHandlerMappingTests {
@PathPatternsParameterizedTest // SPR-8462
void getHandlerMediaTypeNotAccepted(TestRequestMappingInfoHandlerMapping mapping) {
testHttpMediaTypeNotAcceptableException(mapping, "/persons");
testHttpMediaTypeNotAcceptableException(mapping, "/persons/");
if (mapping.getPatternParser() == null) {
testHttpMediaTypeNotAcceptableException(mapping, "/persons.json");
}

View File

@@ -3849,7 +3849,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
@Controller
static class HttpHeadersResponseController {
@RequestMapping(value = "", method = RequestMethod.POST)
@RequestMapping(value = "/", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public HttpHeaders create() throws URISyntaxException {
HttpHeaders headers = new HttpHeaders();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -225,11 +225,6 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("list");
request = new MockHttpServletRequest("GET", "/hotels/");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("list");
request = new MockHttpServletRequest("POST", "/hotels");
response = new MockHttpServletResponse();
getServlet().service(request, response);
@@ -240,11 +235,6 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("show-42");
request = new MockHttpServletRequest("GET", "/hotels/42/");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("show-42");
request = new MockHttpServletRequest("PUT", "/hotels/42");
response = new MockHttpServletResponse();
getServlet().service(request, response);

View File

@@ -6,7 +6,6 @@
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="defaultHandler"><ref bean="starController"/></property>
<property name="rootHandler"><ref bean="mainController"/></property>
<property name="useTrailingSlashMatch" value="true"/>
<property name="urlMap">
<map>
<entry key="/welcome*"><ref bean="otherController"/></entry>
@@ -23,7 +22,6 @@
<bean id="urlMappingWithProps" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="defaultHandler"><ref bean="starController"/></property>
<property name="rootHandler"><ref bean="mainController"/></property>
<property name="useTrailingSlashMatch" value="true"/>
<property name="mappings"><ref bean="mappings"/></property>
</bean>

View File

@@ -4310,9 +4310,7 @@ The following example shows how to use `PathMatchConfigurer`:
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer
.setUseCaseSensitiveMatch(true)
.setUseTrailingSlashMatch(false)
.addPathPrefix("/api",
HandlerTypePredicate.forAnnotation(RestController.class));
.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class));
}
}
----
@@ -4327,9 +4325,7 @@ The following example shows how to use `PathMatchConfigurer`:
fun configurePathMatch(configurer: PathMatchConfigurer) {
configurer
.setUseCaseSensitiveMatch(true)
.setUseTrailingSlashMatch(false)
.addPathPrefix("/api",
HandlerTypePredicate.forAnnotation(RestController::class.java))
.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController::class.java))
}
}
----

View File

@@ -6030,7 +6030,6 @@ The following example shows how to customize path matching in XML configuration:
----
<mvc:annotation-driven>
<mvc:path-matching
trailing-slash="false"
path-helper="pathHelper"
path-matcher="pathMatcher"/>
</mvc:annotation-driven>