[Solved] Cannot call sendError() after the response has been committed

Background of error reporting: when working on the open source project “Ruiji takeout”, after writing the interceptor code, when the front-end logs in, the back-end reports an error as follows:

        

 

Solution:

I found that my code, at the very beginning of the method, has unconditionally released any resources, i.e. filterChain.doFilter(request, response); when this line of code, and then continue to write the code to execute the response, it will report the above error. So, just comment out this line of code.

Read More: