2013-03-13 29 views
2

我正在使用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)設置的響應對象。

的原因是什麼?

請幫忙。

謝謝。

+0

請提供任何指導。請讓我知道是否需要進一步的信息。 – peterwkc 2013-03-14 01:43:22

+0

我試圖禁用sitemesh文件管理器,它已經返回了一些結果,但是沒有使用sitemesh fileter enable返回html。此外,還有警告[org.jboss.as.ee](MSC服務線程1-7) JBAS011006:不安裝可選組件 org.springframework.web.context.request.async.StandardServletAsyncWebRequest 由於異常: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: 無法找到類 的默認構造函數org.springframework.web.context.request.async.StandardServletAsyncWebRequest – peterwkc 2013-03-14 04:45:27

回答

1

由於SiteMesh的過濾器在請求結束做一些後處理,它需要支持Servlet 3異步請求特徵在爲了使該工作。當初始Servlet容器線程退出並且響應保持打開狀態時。如果Sitemesh過濾器不知道這一點,它會嘗試儘早完成處理。

+0

任何具體的解決方案?我可以嘗試最新的sitemesh 3 jar。 – peterwkc 2013-03-18 09:25:34

-1

推薦給您的好心情,返回作爲字符串而不是ModelAndView

+0

我正在使用異步servlet。 – peterwkc 2013-03-26 09:15:58

1

我不是期望sitemesh。但它也是一個servlet,所以他們遵循「命令鏈」模式,這意味着它有可能無法傳送您所需的正確url。你可以發佈你的web配置異步彈簧和web.xml中的sitemesh配置