为了调试目的,我想列出各种webflow上下文作用域(viewScope、flowScope等)中的所有内容(第一个webflow应用程序,试图让它正常工作)。但我似乎不能正确地理解语法。有人能告诉我怎么做吗?我在我的flow.xml里有这个:
<view-state id="createAccount" model="account">
<on-render>
<evaluate expression="flowService.createAccount()" result="flowScope.account" />
</on-render>
<transition on="next" to="applicationInfo" />
</view-state>我的JSP页面中有这样的内容:
<c:forEach items="${flowScope}" var="thisFlowScope" varStatus="thisFlowScopeStatus">
<label>${thisFlowScope.key}</label>
<span>${thisFlowScope.value}</span>
</c:forEach>我希望看到的是与flowScope中的其他所有内容一起打印出来的“帐户”属性/变量。相反,我什么也得不到。我尝试过各种排列,例如"flowRequestContext“而不是"flowScope”。用"flowRequestContext“我得到:
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:255)
org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:219)
org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:137)
javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:227)有人能告诉我怎么做吗?
发布于 2013-08-20 16:13:38
flowScope是MutableAttributeMap。
你不能对这件事发牢骚。这就是为什么使用c:forEach不起作用的原因。
但是:您可以使用${flowRequestContext.flowScope}打印整个地图,但这看起来不太好看。
有一个名为asMap的函数从org.springframework.binding.collection.MapAdaptable继承下来,它将其转换为java.util.Map (当然,这是可迭代的)
发布于 2018-02-07 07:22:34
我在回答Philipp和“user1071914”的基础上增加了我的例子:
flow.xml:
<view-state id="display" view="/WEB-INF/jsp/infoUser.jsp" model="dtoUser">
<on-entry>
<evaluate expression="flowRequestContext.flowScope.asMap()" result="requestScope.flowAsMap" />
<on-entry>
<transition on="next" to="checkUserAction" />
</view-state>
<action-state id="checkUserAction">
...
</action-state>查看JSP:
<c:out value="${requestScope.flowAsMap['myvarflowScope']}" />https://stackoverflow.com/questions/18339093
复制相似问题