我正在使用spring webflow 1.0。我正在上传一个csv文件,解析它,并在继续之前显示结果。用户可以选择下载包含未通过验证的记录的csv文件。当我单击JSP中的链接下载此文件时,webflow将调用表单Action。表单操作通过从响应中获取输出流来写出文件:
HttpServletResponse response = ((ServletExternalContext) context.getExternalContext()).getResponse();
我不想离开我目前正在使用的jsp。我只想下载文件。换句话说,我不想过渡到另一个州。我只想提供动态呈现的文件。一切正常(我不会离开页面,我下载文件),但我的控制台出现以下错误:
_pEncydKfggPHJo8=org.springframework.webflow.engine.NoMatchingTransitionException: No transition was matched on the event(s) signaled by the [1] action(s) that executed in this action state 'downloadErrorReportAction' of flow 'myFlow'; transitions must be defined to handle action result outcomes -- possible flow configuration error? Note: the eventIds signaled were: 'array<String>[[null]]', while the supported set of transitional criteria for this action state is 'array<TransitionCriteria>[[empty]]'
at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:187)
at org.springframework.webflow.engine.State.enter(State.java:191)
at org.springframework.webflow.engine.Transition.execute(Transition.java:212)
at org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
at org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)
Truncated. see log file for complete stacktrace
以下是我的webflow配置的相关部分。
<view-state id="showUploadResults" view="UploadResults3.0">
<render-actions>
<action bean="UploadResultsAction" method="transitionToWebflow"/>
<action bean="UploadResultsAction" method="setupData"/>
</render-actions>
<transition on="submit" to="proceed"/>
<transition on="downloadErrorReport" to="downloadErrorReportAction"/>
</view-state>
<action-state id="downloadErrorReportAction">
<action bean="UploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
</action-state>
答案 0 :(得分:2)
我能够通过定义视图状态并指定渲染操作来完成此操作。
<view-state id="downloadErrorReportAction">
<render-actions>
<action bean="uploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
</render-actions>
</view-state>
我还必须添加上一个操作中的相同转换,因为一旦单击下载链接,您将转换到另一个状态。所以最终的配置如下所示:
<view-state id="showUploadResults" view="UploadResults3.0">
<render-actions>
<action bean="UploadResultsAction" method="transitionToWebflow"/>
<action bean="UploadResultsAction" method="setupData"/>
</render-actions>
<transition on="submit" to="proceed"/>
<transition on="downloadErrorReport" to="downloadErrorReportAction"/>
</view-state>
<view-state id="downloadErrorReportAction">
<render-actions>
<action bean="uploadResultsAction" method="downloadErrorReport" name="downloadErrorReport"/>
</render-actions>
<transition on="submit" to="proceed"/>
</view-state>