4

我正在使用spring webflow 1.0。我正在上传一个 csv 文件,对其进行解析并在继续之前显示结果。用户可以选择下载包含未通过验证的记录的 csv 文件。当我单击 JSP 中的链接下载此文件时,webflow 会调用表单操作。表单操作通过从响应中获取输出流来写出文件:

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>
4

1 回答 1

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>
于 2010-06-17T16:39:57.083 回答