SPR-6528 - PathVariables of type double
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2590 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
b96070163e
commit
67d2f24b59
|
|
@ -88,6 +88,30 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||||
assertEquals(500, response.getStatus());
|
assertEquals(500, response.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void doubles() throws Exception {
|
||||||
|
servlet = new DispatcherServlet() {
|
||||||
|
@Override
|
||||||
|
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
|
||||||
|
throws BeansException {
|
||||||
|
GenericWebApplicationContext wac = new GenericWebApplicationContext();
|
||||||
|
wac.registerBeanDefinition("controller", new RootBeanDefinition(DoubleController.class));
|
||||||
|
RootBeanDefinition mappingDef = new RootBeanDefinition(DefaultAnnotationHandlerMapping.class);
|
||||||
|
mappingDef.getPropertyValues().add("useDefaultSuffixPattern", false);
|
||||||
|
wac.registerBeanDefinition("handlerMapping", mappingDef);
|
||||||
|
wac.refresh();
|
||||||
|
return wac;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
servlet.init(new MockServletConfig());
|
||||||
|
|
||||||
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/lat/1.2/long/3.4");
|
||||||
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||||
|
servlet.service(request, response);
|
||||||
|
|
||||||
|
assertEquals("latitude-1.2-longitude-3.4", response.getContentAsString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ambiguous() throws Exception {
|
public void ambiguous() throws Exception {
|
||||||
initServlet(AmbiguousUriTemplateController.class);
|
initServlet(AmbiguousUriTemplateController.class);
|
||||||
|
|
@ -415,6 +439,17 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public static class DoubleController {
|
||||||
|
|
||||||
|
@RequestMapping("/lat/{latitude}/long/{longitude}")
|
||||||
|
public void testLatLong(@PathVariable Double latitude, @PathVariable Double longitude, Writer writer)
|
||||||
|
throws IOException {
|
||||||
|
writer.write("latitude-" + latitude + "-longitude-" + longitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("hotels")
|
@RequestMapping("hotels")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue