发送 HTTP 响应后执行代码
在基于 Java servlet 的 Web 应用程序中,是否有任何方法可以在发送到客户端的 HttpServletResponse 之后并根据已发送到客户端的 HttpServletResponse 执行某些代码?
In a Java servlet based web application, is there any way to execute some code after and depending on the HttpServletResponse
that has been sent to the client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以:
chain.doFilter(request, response)
方法之后包含代码的Filter
HttpServletResponse
包装在自定义响应对象,它处理您喜欢的任何操作 - 在本例中 - 将OutputStream
替换为记录所需信息的对象You can:
Filter
that has code after thechain.doFilter(request, response)
methodHttpServletResponse
in a custom response object which handles whatever operations you like - in this case - replacing theOutputStream
with one that logs the desired information