Add HttpStatus to ModelAndView

Issue: SPR-13560
This commit is contained in:
Rossen Stoyanchev
2016-01-20 16:54:05 -05:00
parent 29700658d4
commit a5f4aa6824
6 changed files with 89 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ package org.springframework.web.method.support;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.support.BindingAwareModelMap;
@@ -54,6 +55,8 @@ public class ModelAndViewContainer {
private boolean redirectModelScenario = false;
private HttpStatus status;
private final SessionStatus sessionStatus = new SimpleSessionStatus();
private boolean requestHandled = false;
@@ -176,6 +179,22 @@ public class ModelAndViewContainer {
return this.sessionStatus;
}
/**
* Provide a HTTP status that will be passed on to with the
* {@code ModelAndView} used for view rendering purposes.
* @since 4.3
*/
public void setStatus(HttpStatus status) {
this.status = status;
}
/**
* Return the configured HTTP status, if any.
*/
public HttpStatus getStatus() {
return this.status;
}
/**
* Whether the request has been handled fully within the handler, e.g.
* {@code @ResponseBody} method, and therefore view resolution is not