Skip to content

Instantly share code, notes, and snippets.

@keesun
Created April 2, 2012 13:44
Show Gist options
  • Select an option

  • Save keesun/2283511 to your computer and use it in GitHub Desktop.

Select an option

Save keesun/2283511 to your computer and use it in GitHub Desktop.
Spring 3.1's FlashMap API
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