【问题标题】:Form processing page in Spring MVCSpring MVC中的表单处理页面
【发布时间】:2012-06-06 10:12:59
【问题描述】:

我是春季新手,如果问题很愚蠢,请见谅。 我有 Spring MVC 表单,以及基于注释的控制器中的 2 个方法。

@RequestMapping(method = RequestMethod.GET)
public String getUploadForm(Model model) {
    model.addAttribute(new UploadItem());
    initModel(model);
    return "upload/uploadForm";
}

@RequestMapping(method = RequestMethod.POST)
public String create(UploadItem uploadItem, BindingResult result, Model model) throws IOException, ServletException {
    // Some type of file processing...
}

我的业务要求是添加“正在处理任务”页面,因为处理需要几分钟,所以应该通知用户,该任务正在进行中(但不需要进度条)只是简单的按摩:“请等等什么的”

在 Spring 中有没有简单的方法可以做到这一点?

【问题讨论】:

    标签: java spring model-view-controller spring-mvc


    【解决方案1】:

    我认为你所追求的与春天并不完全相关。如果您想在较长的任务运行时显示一些消息,则需要在较长的任务执行时使用 Ajax/JQuery 来显示一些文本/动画。我建议您看一下this 示例,了解如何使用 JQuery 做这样的事情。

    【讨论】:

      【解决方案2】:

      我还建议您在客户端处理此问题。最好的方法之一是您可以使用 jquery ajax 调用服务器,这允许您编写自己的方法来执行直到响应返回。

      【讨论】:

        【解决方案3】:

        thx 伙计们,我正在考虑在后台运行一些线程,然后在服务器端重定向控件,但确实客户端解决方案更好更简单。

        我将使用 jquery/js 显示消息并提交表单,甚至不需要 ajax。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-11-10
          • 2015-02-20
          • 2013-01-18
          • 2015-10-16
          • 2017-12-05
          • 2015-11-23
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多