在Springflow中访问flashattribute
向重定向attrs.addFlashAttribute(“某些”,值)添加值代码>然后重定向到在Springflow中访问flashattribute,spring,spring-webflow-2,Spring,Spring Webflow 2,向重定向attrs.addFlashAttribute(“某些”,值)添加值然后重定向到Springflow 如何在Springflow中访问flashattributesome <on-start> <evaluate expression="do.Action(???)" result="flowScope.someobject" /> </on-start> 试试: 与: @组件 公共最终类WebFlowUtils{ 公共对象getFlashA
Springflow
如何在Springflow
中访问flashattribute
some
<on-start>
<evaluate expression="do.Action(???)" result="flowScope.someobject" />
</on-start>
试试:
与:
@组件
公共最终类WebFlowUtils{
公共对象getFlashAttribute(ExternalContext上下文,字符串attributeName){
Map flashMap=RequestContextUtils.getInputFlashMap((HttpServletRequest)context.getNativeRequest());
return flashMap!=null?flashMap.get(attributeName):null;
}
}
see它谈到了添加,但如何在流XML中访问?requestScope.some或我共享的上一个链接中的requestScope['some'],请尝试将其添加到viewScope。context.getViewScope().put(“some”,some),然后使用viewScope.some或viewScope['some']在流xml中访问它。对于延迟响应,我深表歉意。这种方法的问题是,它是来自Spring控制器的重定向,并且流上下文在控制器中不可用。所以这种方法也行不通。完美的解决方案。非常感谢。非常感谢:)
<evaluate expression="webFlowUtils.getFlashAttribute(externalContext, 'some')"/>
@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;
}
}