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

前端 未结 7 1918
说谎
说谎 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:33

    One thing missing from David's answer above is that you should also override the other form of sendError:

    @Override
    public void sendError(int sc, String msg) throws IOException {
        httpStatus = sc;
        super.sendError(sc, msg);
    }
    

提交回复
热议问题