SPR-5732 - When no type conversion strategy is found on a @Controller handler method bind target, a 500 error code should be returned not a 400.

This commit is contained in:
Arjen Poutsma
2009-05-11 14:52:14 +00:00
parent 800af734d9
commit bf7a947559
8 changed files with 121 additions and 8 deletions

View File

@@ -17,8 +17,8 @@
package org.springframework.web.servlet.mvc.annotation;
import java.io.IOException;
import java.io.Writer;
import java.io.Serializable;
import java.io.Writer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -106,6 +106,7 @@ import org.springframework.web.util.NestedServletException;
/**
* @author Juergen Hoeller
* @author Sam Brannen
* @author Arjen Poutsma
* @since 2.5
*/
public class ServletAnnotationControllerTests {

View File

@@ -74,7 +74,18 @@ public class UriTemplateServletAnnotationControllerTests {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/42/dates/2008-11-18");
MockHttpServletResponse response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals("test-42", response.getContentAsString());
assertEquals(200, response.getStatus());
request = new MockHttpServletRequest("GET", "/hotels/42/dates/2008-foo-bar");
response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals(400, response.getStatus());
initServlet(NonBindingUriTemplateController.class);
request = new MockHttpServletRequest("GET", "/hotels/42/dates/2008-foo-bar");
response = new MockHttpServletResponse();
servlet.service(request, response);
assertEquals(500, response.getStatus());
}
@Test
@@ -276,6 +287,16 @@ public class UriTemplateServletAnnotationControllerTests {
}
@Controller
public static class NonBindingUriTemplateController {
@RequestMapping("/hotels/{hotel}/dates/{date}")
public void handle(@PathVariable("hotel") String hotel, @PathVariable Date date, Writer writer)
throws IOException {
}
}
@Controller
@RequestMapping("/hotels/{hotel}")
public static class RelativePathUriTemplateController {