이제 redirect에도 @Pathvalueable이 적용 가능해졌다.
출처 : http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/servlet/mvc/support/RedirectAttributes.html
org.springframework.web.servlet.mvc.support
Interface RedirectAttributes
- All Superinterfaces:
- Model
- All Known Implementing Classes:
- RedirectAttributesModelMap
public interface RedirectAttributes
- extends Model
A specialization of the Model
interface that controllers can use to select attributes for a redirect scenario. Since the intent of adding redirect attributes is very explicit -- i.e. to be used for a redirect URL, attribute values may be formatted as Strings and stored that way to make them eligible to be appended to the query string or expanded as URI variables in org.springframework.web.servlet.view.RedirectView
.
This interface also provides a way to add flash attributes. For a general overview of flash attributes see FlashMap
. You can use RedirectAttributes
to store flash attributes and they will be automatically propagated to the "output" FlashMap of the current request.
Example usage in an @Controller
:
@RequestMapping(value = "/accounts", method = RequestMethod.POST) public String handle(Account account, BindingResult result, RedirectAttributes redirectAttrs) { if (result.hasErrors()) { return "accounts/new"; } // Save account ... redirectAttrs.addAttribute("id", account.getId()).addFlashAttribute("message", "Account created!"); return "redirect:/accounts/{id}"; }
A RedirectAttributes model is empty when the method is called and is never used unless the method returns a redirect view name or a RedirectView.
After the redirect, flash attributes are automatically added to the model of the controller that serves the target URL.
- Since:
- 3.1
- Author:
- Rossen Stoyanchev
'Hot Tech Reference > Spring Framework' 카테고리의 다른 글
@ResponseBody 이해하기 (0) | 2014.01.27 |
---|---|
spring mailSender를 이용한 메일보내기 (0) | 2012.10.11 |
[validation] Spring 3.x에 validation추가하기 (2) | 2012.06.19 |
[log4j] spring 3.x에서 log4j 사용하기 (0) | 2012.06.19 |
[SPRING]@valid를 이용한 스프링3 validation 체크 (0) | 2012.06.12 |