Created
April 2, 2012 13:44
-
-
Save keesun/2283511 to your computer and use it in GitHub Desktop.
Spring 3.1's FlashMap API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FlashAPI { | |
| @Test | |
| public void makeFlashMap(){ | |
| FlashMap fm = new FlashMap(); | |
| fm.put("message", "hi"); | |
| fm.setTargetRequestPath("/user/list"); | |
| fm.startExpirationPeriod(10); | |
| } | |
| @Test | |
| public void makeFlashMapWithUtil(){ | |
| MockHttpServletRequest req = new MockHttpServletRequest(); | |
| FlashMap fm = RequestContextUtils.getOutputFlashMap(req); | |
| fm.put("message", "hi"); | |
| } | |
| @Test | |
| public void takeOutFromFlashMap(){ | |
| MockHttpServletRequest req = new MockHttpServletRequest(); | |
| Map<String, ?> fm = RequestContextUtils.getInputFlashMap(req); | |
| String flashMessage = (String) fm.get("message"); | |
| Model model = new ExtendedModelMap(); | |
| model.addAttribute("flashMessage", flashMessage); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment