Servlet 3.0 或 Glassfish 问题?在注释中时,Web 应用程序会忽略过滤器的 asyncSupported
我向我的网络应用程序添加了一个过滤器(它已经支持异步操作),但忘记在过滤器上插入正确的注释以保留异步支持。问题很容易解决。我将以下注释放在过滤器类中,最终看起来像这样:
@WebFilter(asyncSupported=true)
public class MainFilter implements Filter
{
...
}
但是,重新部署后,异步操作仍然不受支持,给了我这个错误:
请求在过滤器或 servlet 的范围内,但过滤器或 servlet 不 支持异步操作
我能够通过删除注释并将其等效项放置在 web.xml 中来纠正问题:
<前><代码><过滤器> <过滤器名称>MainFilter <过滤器类>com.MyWebApp.Filters.MainFilter <支持异步>true
我感到困惑的是,容器似乎尊重 servlet 文件中的 asyncSupported 注释,但不尊重过滤器。是否有具体原因,或者这是 GlassFish 3.0 的错误?
I added a filter to my web-app (which already supports asynchronous operations), and forgot to insert the proper annotation on the filter to to preserve asynchronous support. Easy problem to solve. I put the following the annotation in the filter class, which ends up looking like this:
@WebFilter(asyncSupported=true)
public class MainFilter implements Filter
{
...
}
However, after redeploying, asynchronous operations remained unsupported, giving me this error:
Request is within the scope of a filter or servlet that does not
support asynchronous operations
I was able to rectify the problem by removing the annotation, and placing its equivalent in web.xml:
<filter> <filter-name>MainFilter</filter-name> <filter-class>com.MyWebApp.Filters.MainFilter</filter-class> <async-supported>true</async-supported> </filter>
What I'm confused about is the fact that the container seems to respect the asyncSupported annotation in servlet files, but does not for filters. Is there a specific reason why, or is this a GlassFish 3.0 bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论