fixed interaction with ControllerClassNameHandlerMapping (as reported by Rossen)
This commit is contained in:
parent
87eb3f970e
commit
ccc7d0f53f
|
|
@ -137,6 +137,30 @@ public class ServletAnnotationControllerTests {
|
||||||
assertEquals("test", response.getContentAsString());
|
assertEquals("test", response.getContentAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void emptyRequestMapping() throws Exception {
|
||||||
|
servlet = new DispatcherServlet() {
|
||||||
|
@Override
|
||||||
|
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
|
||||||
|
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||||
|
wac.registerBeanDefinition("controller", new RootBeanDefinition(ControllerWithEmptyMapping.class));
|
||||||
|
RootBeanDefinition mbd = new RootBeanDefinition(ControllerClassNameHandlerMapping.class);
|
||||||
|
mbd.getPropertyValues().add("excludedPackages", null);
|
||||||
|
mbd.getPropertyValues().add("order", 0);
|
||||||
|
wac.registerBeanDefinition("mapping", mbd);
|
||||||
|
wac.registerBeanDefinition("mapping2", new RootBeanDefinition(DefaultAnnotationHandlerMapping.class));
|
||||||
|
wac.refresh();
|
||||||
|
return wac;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
servlet.init(new MockServletConfig());
|
||||||
|
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/servletannotationcontrollertests.controllerwithemptymapping");
|
||||||
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
|
servlet.service(request, response);
|
||||||
|
assertEquals("test", response.getContentAsString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customAnnotationController() throws Exception {
|
public void customAnnotationController() throws Exception {
|
||||||
initServlet(CustomAnnotationController.class);
|
initServlet(CustomAnnotationController.class);
|
||||||
|
|
@ -1350,10 +1374,10 @@ public class ServletAnnotationControllerTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @noinspection UnusedDeclaration */
|
@Controller
|
||||||
private static class BaseController {
|
private static class ControllerWithEmptyMapping {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
@RequestMapping
|
||||||
public void myPath2(HttpServletResponse response) throws IOException {
|
public void myPath2(HttpServletResponse response) throws IOException {
|
||||||
response.getWriter().write("test");
|
response.getWriter().write("test");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue