Do not use ParsingPathMatcher by default in Spring MVC

This commit is contained in:
Brian Clozel
2017-02-08 14:23:14 +01:00
parent 18c04815a7
commit 47ac3379ea
12 changed files with 43 additions and 30 deletions

View File

@@ -37,9 +37,11 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
import org.springframework.web.util.ParsingPathMatcher;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* Test fixture with a {@link InterceptorRegistry}, two {@link HandlerInterceptor}s and two
@@ -153,7 +155,7 @@ public class InterceptorRegistryTests {
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
PathMatcher pathMatcher = new ParsingPathMatcher();
PathMatcher pathMatcher = new AntPathMatcher();
List<HandlerInterceptor> result = new ArrayList<>();
for (Object interceptor : this.registry.getInterceptors()) {
if (interceptor instanceof MappedInterceptor) {

View File

@@ -18,6 +18,7 @@ package org.springframework.web.servlet.config.annotation;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -83,7 +84,6 @@ import org.springframework.web.servlet.resource.ResourceUrlProviderExposingInter
import org.springframework.web.servlet.view.BeanNameViewResolver;
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;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
@@ -321,7 +321,7 @@ public class WebMvcConfigurationSupportTests {
assertNotNull(urlPathHelper);
assertNotNull(pathMatcher);
assertEquals(ParsingPathMatcher.class, pathMatcher.getClass());
assertEquals(AntPathMatcher.class, pathMatcher.getClass());
}
private ApplicationContext initContext(Class<?>... configClasses) {

View File

@@ -16,8 +16,6 @@
package org.springframework.web.servlet.handler;
import static org.junit.Assert.*;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Comparator;
@@ -38,9 +36,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.support.StaticWebApplicationContext;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.util.ParsingPathMatcher;
import org.springframework.web.util.UrlPathHelper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Test for {@link AbstractHandlerMethodMapping}.
@@ -245,7 +246,7 @@ public class HandlerMethodMappingTests {
private UrlPathHelper pathHelper = new UrlPathHelper();
private PathMatcher pathMatcher = new ParsingPathMatcher();
private PathMatcher pathMatcher = new AntPathMatcher();
public MyHandlerMethodMapping() {

View File

@@ -18,16 +18,18 @@ package org.springframework.web.servlet.mvc;
import org.junit.Test;
import static org.junit.Assert.*;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockHttpServletResponse;
import org.springframework.ui.ModelMap;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.ParsingPathMatcher;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author Juergen Hoeller
@@ -36,7 +38,7 @@ import org.springframework.web.util.ParsingPathMatcher;
*/
public class UrlFilenameViewControllerTests {
private PathMatcher pathMatcher = new ParsingPathMatcher();
private PathMatcher pathMatcher = new AntPathMatcher();
@Test