IllegalStateException: Not supported on AsyncContext.startAsync(req, res)

后端 未结 2 1407
别那么骄傲
别那么骄傲 2020-12-10 03:34

I have created a servlet 3.0 to explore asynchronous request processing:

@WebServlet(name=\"MyTest\", urlPatterns={\"/MyTest\"}, asyncSupported=true)
public          


        
相关标签:
2条回答
  • 2020-12-10 04:34

    Please check if you have any request filter which is not enabled to support async. Either you can remove the filter (temporarily) or mark it to support async.

    0 讨论(0)
  • 2020-12-10 04:37

    I checked out Tomcat's code and saw that the asyncSupported variable has to be explicitly set to true. That's why you are getting req.isAsyncSupported() == false.

    You could try to set the async attribute in the HttpServletRequest object to true by one of the following methods.

    req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
    

    or

    ((org.apache.catalina.connector.Request)req).setAsyncSupported(true);
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题