如何避免请求设置 ASYNC_SUPPORTED=true 以在 Tomcat 7 上启用异步 servlet 3.0 处理? [英] How to avoid request set ASYNC_SUPPORTED=true to enable async servlet 3.0 processing on Tomcat 7?
问题描述
根据此问题报告的问题,解决方案是发现:
Following an issue reported on this question, a solution was found:
req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true);
这看起来有点奇怪,并不是真正的可移植"代码(它不会受到伤害,但是......).它似乎特定于 Tomcat 7.我使用的是 NetBeans 7.0.1 提供的 Tomcat 7.0.14.
This seems a bit strange and is not really 'portable' code (it won't hurt, but...). It seems specific to Tomcat 7. I am using Tomcat 7.0.14 as delivered by NetBeans 7.0.1.
我找不到说明有必要在 servlet 3.0 中使用 catalina 属性启用异步请求处理的文档.我找不到说明在 Tomcat 配置级别也需要特殊内容的文档.
I could not find documentation indicating it is necessary to enable async request processing in servlet 3.0 with a catalina attribute. I could not find documentation indicating something special was necessary at the Tomcat configuration level too.
有没有办法避免必须在每个请求中设置 ASYNC_SUPPORTED=true
以在 Tomcat 7 中启用异步 servlet 3.0 处理?
Is there a way to avoid having to set ASYNC_SUPPORTED=true
in each request to enable async servlet 3.0 processing in Tomcat 7?
推荐答案
首先要检查的几件事:
确保对请求进行操作的任何过滤器也支持异步(如其中一个答案中所述)你引用了).
Make sure any filters that operate on the request also support async (as addressed in one of the answers to the question you referenced).
确保您使用的是 Servlet 3.0 web.xml - 例如:
Make sure you're using a Servlet 3.0 web.xml - for example:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
这篇关于如何避免请求设置 ASYNC_SUPPORTED=true 以在 Tomcat 7 上启用异步 servlet 3.0 处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!