Fix for ModelAndView.status not working with RedirectView
This commit is contained in:
committed by
Arjen Poutsma
parent
14f24f43d7
commit
9261766677
@@ -1897,6 +1897,18 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
assertThat(response.getForwardedUrl()).isEqualTo("view");
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
void modelAndViewWithStatusForRedirect(boolean usePathPatterns) throws Exception {
|
||||
initDispatcherServlet(ModelAndViewController.class, usePathPatterns);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/redirect");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
getServlet().service(request, response);
|
||||
|
||||
assertThat(response.getStatus()).isEqualTo(307);
|
||||
assertThat(response.getRedirectedUrl()).isEqualTo("/path");
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest // SPR-14796
|
||||
void modelAndViewWithStatusInExceptionHandler(boolean usePathPatterns) throws Exception {
|
||||
initDispatcherServlet(ModelAndViewController.class, usePathPatterns);
|
||||
@@ -3872,6 +3884,11 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||
return new ModelAndView("view", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
@RequestMapping("/redirect")
|
||||
public ModelAndView methodWithHttpStatusForRedirect(MyEntity object) {
|
||||
return new ModelAndView("redirect:/path", HttpStatus.TEMPORARY_REDIRECT);
|
||||
}
|
||||
|
||||
@RequestMapping("/exception")
|
||||
public void raiseException() throws Exception {
|
||||
throw new TestException();
|
||||
|
||||
Reference in New Issue
Block a user