How can I get the HTTP status code out of a ServletResponse in a ServletFilter?

前端 未结 7 1931
说谎
说谎 2020-11-28 04:16

I\'m trying to report on every HTTP status code returned from my webapp. However the status code does not appear to be accessible via the ServletResponse, or even if I cast

相关标签:
7条回答
  • 2020-11-28 04:44

    Write an HttpServletResponseWrapper and override all the setStatus(), sendError(), and sendRedirect() methods to log everything. Write a Filter that swaps your wrapper in for the response object on every request.

    0 讨论(0)
提交回复
热议问题