Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Springflow中访问flashattribute_Spring_Spring Webflow 2 - Fatal编程技术网

在Springflow中访问flashattribute

在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

向重定向attrs.addFlashAttribute(“某些”,值)添加值然后重定向到
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;
    }
}