I use,
redirectAttributes.addFlashAttribute("msg","Level complete")
to access message on the redirected jsp.
How can I use this redirect attribute when I am redirecting to a Webflow ?
When flash attribute is used to send data from one controller to a webflow we have to bind redirected flash attribute (from controller) to the response JSP page of the webflow. For this purpose we can maintain a backend FormAction class to bind the value to any scope of webflow. In flow xml we can can call custom method on entry of a view state.
Custom Method of FormAction class would be like
public void setupReferenceData(RequestContext context) throws Exception {
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getNativeRequest();
Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request);
if (inputFlashMap != null) {
String flash = (String) inputFlashMap.get("flash");
context.getRequestScope().put("flash1", flash);
}
}
This method call should be included in the entry section of a view state. So flow xml should have these portion.
<view-state id="request" view="hello">
<on-entry>
<evaluate expression="requestAction.setupReferenceData" />
</on-entry>
<transition on="next" to="helloend"/>
</view-state>
来源:https://stackoverflow.com/questions/23216312/accessing-flash-attributes-in-spring-web-flow