Deprecate and set trailingSlash option to false
Closes gh-28552
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user