Access flashattribute in Springflow

2019-04-15 10:31发布

问题:

Added value to redirectAttrs.addFlashAttribute("some", value); and then redirect to Springflow

How to access flashattribute some in Springflow?

<on-start>
 <evaluate expression="do.Action(???)" result="flowScope.someobject" />
</on-start>

回答1:

try:

<evaluate expression="webFlowUtils.getFlashAttribute(externalContext, 'some')"/>

with:

@Component
public final class WebFlowUtils {

    public Object getFlashAttribute(ExternalContext context, String attributeName) {
        Map<String, ?> flashMap = RequestContextUtils.getInputFlashMap((HttpServletRequest) context.getNativeRequest());
        return flashMap != null ? flashMap.get(attributeName) : null;
    }
}