Merge branch '5.3.x'
This commit is contained in:
commit
ce253041c5
|
@ -1393,6 +1393,7 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (mv.getStatus() != null) {
|
if (mv.getStatus() != null) {
|
||||||
|
request.setAttribute(View.RESPONSE_STATUS_ATTRIBUTE, mv.getStatus());
|
||||||
response.setStatus(mv.getStatus().value());
|
response.setStatus(mv.getStatus().value());
|
||||||
}
|
}
|
||||||
view.render(mv.getModelInternal(), request, response);
|
view.render(mv.getModelInternal(), request, response);
|
||||||
|
|
|
@ -1896,6 +1896,18 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||||
assertThat(response.getForwardedUrl()).isEqualTo("view");
|
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
|
@PathPatternsParameterizedTest // SPR-14796
|
||||||
void modelAndViewWithStatusInExceptionHandler(boolean usePathPatterns) throws Exception {
|
void modelAndViewWithStatusInExceptionHandler(boolean usePathPatterns) throws Exception {
|
||||||
initDispatcherServlet(ModelAndViewController.class, usePathPatterns);
|
initDispatcherServlet(ModelAndViewController.class, usePathPatterns);
|
||||||
|
@ -3884,6 +3896,11 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
|
||||||
return new ModelAndView("view", HttpStatus.UNPROCESSABLE_ENTITY);
|
return new ModelAndView("view", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/redirect")
|
||||||
|
public ModelAndView methodWithHttpStatusForRedirect(MyEntity object) {
|
||||||
|
return new ModelAndView("redirect:/path", HttpStatus.TEMPORARY_REDIRECT);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/exception")
|
@RequestMapping("/exception")
|
||||||
public void raiseException() throws Exception {
|
public void raiseException() throws Exception {
|
||||||
throw new TestException();
|
throw new TestException();
|
||||||
|
|
Loading…
Reference in New Issue