Browse Source

SPR-6906 - Combination of ControllerClassNameHandlerMapping and @RequestMappings with file extensions results in exception

pull/23217/head
Arjen Poutsma 15 years ago
parent
commit
21fd150894
  1. 4
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/ControllerClassNameController.java
  2. 11
      org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

4
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/FooController.java → 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; @@ -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);
}

11
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/annotation/UriTemplateServletAnnotationControllerTests.java

@ -350,7 +350,7 @@ public class UriTemplateServletAnnotationControllerTests { @@ -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 { @@ -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());
}

Loading…
Cancel
Save