From 47ac3379ea1f49d6ced1e82a5649441a964eed68 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 8 Feb 2017 14:23:14 +0100 Subject: [PATCH] Do not use ParsingPathMatcher by default in Spring MVC --- .../web/cors/UrlBasedCorsConfigurationSource.java | 5 +++-- .../springframework/web/servlet/ResourceServlet.java | 5 +++-- .../config/annotation/WebMvcConfigurationSupport.java | 7 ++++--- .../web/servlet/handler/AbstractHandlerMapping.java | 5 +++-- .../web/servlet/mvc/WebContentInterceptor.java | 5 +++-- .../mvc/condition/PatternsRequestCondition.java | 5 +++-- .../mvc/method/annotation/MvcUriComponentsBuilder.java | 5 +++-- .../web/servlet/resource/ResourceUrlProvider.java | 5 +++-- .../config/annotation/InterceptorRegistryTests.java | 8 +++++--- .../annotation/WebMvcConfigurationSupportTests.java | 4 ++-- .../web/servlet/handler/HandlerMethodMappingTests.java | 9 +++++---- .../servlet/mvc/UrlFilenameViewControllerTests.java | 10 ++++++---- 12 files changed, 43 insertions(+), 30 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java index a5843aaf8e0..f4c212544f5 100644 --- a/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java +++ b/spring-web/src/main/java/org/springframework/web/cors/UrlBasedCorsConfigurationSource.java @@ -19,11 +19,12 @@ package org.springframework.web.cors; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; + import javax.servlet.http.HttpServletRequest; +import org.springframework.util.AntPathMatcher; import org.springframework.util.Assert; import org.springframework.util.PathMatcher; -import org.springframework.web.util.ParsingPathMatcher; import org.springframework.web.util.UrlPathHelper; /** @@ -40,7 +41,7 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource private final Map corsConfigurations = new LinkedHashMap<>(); - private PathMatcher pathMatcher = new ParsingPathMatcher(); + private PathMatcher pathMatcher = new AntPathMatcher(); private UrlPathHelper urlPathHelper = new UrlPathHelper(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java index 1d18ad6cc5c..e927935005d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/ResourceServlet.java @@ -17,15 +17,16 @@ package org.springframework.web.servlet; import java.io.IOException; + import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; import org.springframework.util.StringUtils; import org.springframework.web.context.support.ServletContextResource; -import org.springframework.web.util.ParsingPathMatcher; /** * Simple servlet that can expose an internal resource, including a @@ -181,7 +182,7 @@ public class ResourceServlet extends HttpServletBean { * @see org.springframework.util.AntPathMatcher */ protected PathMatcher getPathMatcher() { - return new ParsingPathMatcher(); + return new AntPathMatcher(); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 85d5e30aced..1f83e3e6536 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; + import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -55,6 +56,7 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter; import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; import org.springframework.http.converter.xml.SourceHttpMessageConverter; +import org.springframework.util.AntPathMatcher; import org.springframework.util.ClassUtils; import org.springframework.util.PathMatcher; import org.springframework.validation.Errors; @@ -93,7 +95,6 @@ import org.springframework.web.servlet.resource.ResourceUrlProvider; import org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.ViewResolverComposite; -import org.springframework.web.util.ParsingPathMatcher; import org.springframework.web.util.UrlPathHelper; /** @@ -140,7 +141,7 @@ import org.springframework.web.util.UrlPathHelper; * exception types * * - *

Registers an {@link ParsingPathMatcher} and a {@link UrlPathHelper} + *

Registers an {@link AntPathMatcher} and a {@link UrlPathHelper} * to be used by: *