0

我正在使用 Spring MVC 实现一个基于 Web 的 Java 应用程序。

我现在正在做的是提供一个页面,允许用户从一组单选按钮中进行选择,并通过单击“提交”按钮以 CSV 格式导出一组数据。

但是,我遇到了一个情况。

用户下载一个 CSV 文件后,无论何时想要下载另一个文件,如果再次单击“提交”按钮,下载过程将不会被触发,并会显示“操作已提交。等待操作完成”的对话框。会出现。

这是我的代码:

<form:form action="handle_export?user_id=${userId}" method="post">
                <div>
                    <table>
                        <tr>
                            <td>
                                <input id="set0" type="radio" name="exportType" value="0"/>
                            </td>
                            <td>
                                <label for="set0">dataset0 Export</label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input id="set1" type="radio" name="exportType" value="1"/>
                            </td>
                            <td>
                                <label for="set1">dataset1  Export</label>
                            </td>
                        </tr>
                    </table>
                </div>

            <input type="button" class="submit button-1" value="Download" name="bottom_Download" />
    </form:form>

我可以多次触发“提交”按钮吗?

非常感谢。

4

1 回答 1

0

我一直在与黑板作斗争,我已经解决了:

- 从 FORM 中删除“动作” -
在 JS 上创建一个函数,例如:generateCSV() - 函数是这样的:

var userid = document.getElementById('userid');
window.open('handle_export?user_id=' + userid);

在 handle_export 上,检索以下值:

String userid = request.getParameter("userid");
// ...
// generate and download file

这样,它在新窗口中打开,黑板不会显示“操作已提交。等待操作完成”的对话框。.

我希望这会有所帮助,问候。

于 2016-10-27T12:24:52.077 回答