title: Spring Boot add header in forthcoming response by exception or AOP
body: <p>How can I add a header in the response to avoid interrupting normal service process? This operation I want to add in <em>OncePerRequestFilter</em> and maybe add header by AOP or Exception. Because this will not affect a lot to my original code.</p>
  <p>My question:</p>
  <p>If the token is expired, which is in the header of request? I want refresh the token and add the new token into the header of response. This operation will not affect normal service logic, which means it also has a normal body by <em>controller</em>.</p>
  <pre><code>Assess-Token: &quot;xxx&quot;
  Connection: Keep-Alive
  
  {
  // normal serivce response in body
  }
  
  </code></pre>
  <p>Now, I could only response the new refreshed token in body. This operation will be interrupted for all service in this request. Which like this:</p>
  <pre><code>Connection: Keep-Alive
  
  {
  Assess-Token: &quot;xxx&quot; // normal service has been interrupted, only token
  }
  </code></pre>
  <p>Thank you in advance.</p>