【问题标题】:Spring Asynchronous Processing Does not Return To ViewSpring异步处理不返回查看
【发布时间】:2013-03-13 09:50:57
【问题描述】:

我正在使用 Spring MVC 异步处理,但控制器没有在 Web 浏览器上返回视图。

@RequestMapping(value = "/generateGM", method = RequestMethod.POST)
    public Callable<ModelAndView> generateGMReport(@RequestParam("countryCode") int countryCode, ModelAndView mv) {

        Callable<ModelAndView> c = new GenericCallable(countryCode, reportDao, mv);

        return c;
    }

@Override
    public ModelAndView call() throws Exception {

        List<CostReport> gmList = reportDao.generateGrossMarginReport(countryCode);

        mv.setViewName("gmReport");
        mv.addObject("gmList", gmList);

        return mv;
    }

我曾尝试修改代码以返回 Callable,但它仍然没有返回到指定的视图名称。

我正在使用 JBoss 7.1。

部署时出现警告:

WARN  [org.jboss.as.ee] (MSC service thread 1-7) 

JBAS011006: Not installing optional component 

org.springframework.web.context.request.async.StandardServletAsyncWebRequest 
due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: 
JBAS011054: 
Could not find default constructor for class 
org.springframework.web.context.request.async.StandardServletAsyncWebRequest

原因:sitemesh 可能无法从 Spring MVC 框架(AsynContext)设置响应对象。

是什么原因?

请帮忙。

谢谢。

【问题讨论】:

  • 请提供任何指导。如果需要更多信息,请告诉我。
  • 我试图禁用 sitemesh 过滤器,它返回了一些结果,但是启用了 sitemesh 过滤器后没有返回 html。此外,还有 WARN [org.jboss.as.ee] (MSC service thread 1-7) JBAS011006: Not installed optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to exception: org.jboss.as .server.deployment.DeploymentUnitProcessingException: JBAS011054: 找不到类 org.springframework.web.context.request.async.StandardServletAsyncWebRequest 的默认构造函数

标签: spring servlets spring-mvc asynchronous


【解决方案1】:

由于 Sitemesh 过滤器会在请求结束时进行一些后处理,因此它需要支持 Servlet 3 异步请求功能才能使其正常工作。当初始 Servlet 容器线程退出并且响应保持打开状态时。如果 Sitemesh 过滤器没有意识到这一点,它将尝试提前完成处理。

【讨论】:

  • 任何具体的解决方案?我可以试试最新的 sitemesh 3 jar。
【解决方案2】:

我不是对 sitemesh 的期望。但它也是一个 servlet,因此它们遵循“命令链”模式,这意味着它可能无法传输您需要的正确 url。您可以在 web.xml 中发布异步 spring 和 sitemesh 配置的配置吗

【讨论】:

    【解决方案3】:

    这可能会有所帮助。返回为 String 而不是 ModelAndView

    【讨论】:

      猜你喜欢
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-20
      • 2022-07-29
      • 2014-06-01
      • 1970-01-01
      • 2018-09-01
      • 2016-08-08
      相关资源
      最近更新 更多