'I have two filters in a Spring Boot project. Why the response.isCommited() became true when the response go through the first filter

I have two filters, and one of them needs to setting headers into the response.

response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE");
response.setHeader("Access-Control-Allow-Headers", "version_id,subsystem,authorization,x-requested-with,content-type,token");

Another one is a filter to verify token. If I make the token filter is the first filter, the headers filter can't set the headers, because response.isCommitted() became true. I want to know why response.isCommitted() become true. Thank you for reading and answering!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source