描述的是关系到Tomcat的一个bug这个问题在这里,这里和这里。
可能的解决方案:
- 使用更稳定的Tomcat版本,例如Tomcat 7.0.47,该错误已得到修复。
- 使用更高级的调度程序,例如org.springframework.web.servlet.DispatcherServlet
- 按照此处的建议覆盖HttpServlet :
public class AsyncServlet extends HttpServlet {protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.isAsyncStarted()) { response.getWriter().write("asyncResult=" + request.getAttribute("asyncResult")); } else { final AsyncContext asyncContext = request.startAsync(request, response); asyncContext.addListener(new AsyncListener() { public void onTimeout(AsyncEvent event) throws IOException { request.setAttribute("asyncResult", "timeoutn"); asyncContext.dispatch(); } public void onStartAsync(AsyncEvent event) throws IOException { } public void onError(AsyncEvent event) throws IOException { } public void onComplete(AsyncEvent event) throws IOException { } }); asyncContext.setTimeout(5000L); }}}



