Servlet 3.0 或 Glassfish 问题?在注释中时,Web 应用程序会忽略过滤器的 asyncSupported

发布于 2025-01-07 10:01:16 字数 663 浏览 4 评论 0原文

我向我的网络应用程序添加了一个过滤器(它已经支持异步操作),但忘记在过滤器上插入正确的注释以保留异步支持。问题很容易解决。我将以下注释放在过滤器类中,最终看起来像这样:

@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文