gpt4 book ai didi

spring-webflow - Spring webflow 1.0 - 下载文件

转载 作者:行者123 更新时间:2023-12-04 06:49:54 27 4
gpt4 key购买 nike

我正在使用 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>

最佳答案

我能够通过定义一个 View 状态并指定一个渲染 Action 来做到这一点。

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

关于spring-webflow - Spring webflow 1.0 - 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3056119/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com