Servlet的3.0异步支持的不工作 [英] Servlet 3.0 Async-supported does not work
本文介绍了Servlet的3.0异步支持的不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的web.xml
Here is my web.xml
<filter>
<filter-name>pollingTest</filter-name>
<filter-class>
webapp.controller.core.servlet.PollingService
</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>pollingTest</filter-name>
<url-pattern>/app/poll</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
下面是类:
public class PollingService implements Filter {
Logger logger = LoggerFactory.getLogger(getClass());
@Override
public void destroy() {
logger.info("Destroy");
}
@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
logger.info("Running");
req.startAsync(req, res);
this.doFilter(req, res, chain);
return;
}
@Override
public void init(FilterConfig arg0) throws ServletException {
logger.info("Init=");
}
}
我在GlassFish还对Tomcat 7的运行,得到了异常:
I run it on glassfish and also on tomcat 7, got exception:
java.lang.IllegalStateException: Request is within the scope of a filter or servlet that does not support asynchronous operations
at org.apache.catalina.connector.Request.startAsync(Request.java:3657)
at org.apache.catalina.connector.Request.startAsync(Request.java:3633)
at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1053)
at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:450)
谁能帮我在这?非常感谢。
Who can help me on this? thanks a lot.
推荐答案
由于你的servlet和链中的任何其它过滤器必须具有&LT;异步支持&GT;真&LT; /异步支持&GT;
在web.xml中。
Because your servlet and any other filter in chain must have <async-supported>true</async-supported>
in web.xml.
这篇关于Servlet的3.0异步支持的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文