HttpServletResponseWrapper 状态代码 = 0
我正在使用 HttpServletResponseWrapper 捕获 servlet 过滤器中的状态代码。看起来效果很好。
当一切正常时,我的状态为 200。但是,当应用程序服务器找不到请求的项目时,我会返回 0。但在浏览器中它显示为 404。
有人可以解释一下吗?
编辑:这是一个 JAX-RS Web 应用程序,所以我猜测如果应用程序服务器在不设置状态的情况下无法匹配它返回的路径,那么当 Web 服务器看到状态 0 时,它会将其替换为 404。这听起来怎么样正确的?
I am using HttpServletResponseWrapper to capture the status code in a servlet filter. It seems to work fine.
I get a status of 200 when everything is ok. However when the app server cant find the requested item, I get back a 0. but in the browser it shows up as a 404.
Can someone explain this?
EDIT: This is a JAX-RS web app so I am guessing that if the app server can't match the path it returns without setting a status, then when the webserver see a status of 0 it replaces it with 404. Does this sound right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我迟到了,但答案可能仍然有用:
在 HttpServletResponseWrapper 中,需要实现这些方法:
在 404 的情况下,不会调用 setStatus,而是调用 sendError,您需要捕获那里的状态。
I am late but probably the answer is still useful:
In the HttpServletResponseWrapper these methods need to be implemented:
On case of 404 the setStatus is not called but sendError, you need to catch the status there.