From 21fd1508949b9c3d046ee4b5290313c09666aa3f Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 9 Mar 2010 10:29:01 +0000 Subject: [PATCH] SPR-6906 - Combination of ControllerClassNameHandlerMapping and @RequestMappings with file extensions results in exception --- ...roller.java => ControllerClassNameController.java} | 4 ++-- .../UriTemplateServletAnnotationControllerTests.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) rename org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/{FooController.java => ControllerClassNameController.java} (91%) diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/FooController.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ControllerClassNameController.java similarity index 91% rename from org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/FooController.java rename to org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ControllerClassNameController.java index b1046bbb1c..a7f7888f9b 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/FooController.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ControllerClassNameController.java @@ -26,9 +26,9 @@ import org.springframework.web.bind.annotation.RequestMethod; /** @author Arjen Poutsma */ @Controller -public class FooController { +public class ControllerClassNameController { - @RequestMapping(value = "{id}", method = RequestMethod.GET) + @RequestMapping(value = {"{id}", "{id}.*"}, method = RequestMethod.GET) public void plain(Writer writer, @PathVariable("id") String id) throws IOException { writer.write("plain-" + id); } diff --git a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java index f14221b611..c3fe460aad 100644 --- a/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java +++ b/org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java @@ -350,7 +350,7 @@ public class UriTemplateServletAnnotationControllerTests { protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException { GenericWebApplicationContext wac = new GenericWebApplicationContext(); - wac.registerBeanDefinition("controller", new RootBeanDefinition(FooController.class)); + wac.registerBeanDefinition("controller", new RootBeanDefinition(ControllerClassNameController.class)); RootBeanDefinition mapping = new RootBeanDefinition(ControllerClassNameHandlerMapping.class); mapping.getPropertyValues().add("excludedPackages", null); wac.registerBeanDefinition("handlerMapping", mapping); @@ -360,15 +360,20 @@ public class UriTemplateServletAnnotationControllerTests { }; servlet.init(new MockServletConfig()); - MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/bar"); + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/controllerclassname/bar"); MockHttpServletResponse response = new MockHttpServletResponse(); servlet.service(request, response); assertEquals("plain-bar", response.getContentAsString()); - request = new MockHttpServletRequest("GET", "/foo/bar.pdf"); + request = new MockHttpServletRequest("GET", "/controllerclassname/bar.pdf"); response = new MockHttpServletResponse(); servlet.service(request, response); assertEquals("pdf-bar", response.getContentAsString()); + + request = new MockHttpServletRequest("GET", "/controllerclassname/bar.do"); + response = new MockHttpServletResponse(); + servlet.service(request, response); + assertEquals("plain-bar", response.getContentAsString()); }