title: automatically add header to every response
body: <p>I want to add this header "Access-Control-Allow-Origin", "*" to every response made to the client whenever a request has made for rest controllers in my application to allow cross origin resource sharing Currently I 'm manually adding this header to each and every method like this</p>
  
  <pre><code>HttpHeaders headers = new HttpHeaders();
  headers.add("Access-Control-Allow-Origin", "*");
  </code></pre>
  
  <p>Its working but its very frustrating . I found webContentInterceptor in spring docs which allow us to modify headers on each response </p>
  
  <pre><code>&lt;mvc:interceptors&gt;
  &lt;bean id="webContentInterceptor" 
  class="org.springframework.web.servlet.mvc.WebContentInterceptor"&gt;
  &lt;property name="Access-Control-Allow-Origin" value="*"/&gt;
  &lt;/bean&gt;
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p>but when i use this it throws error that property not found of name Access-Control-Allow-Origin so is there any other way we can automatically add header to every response</p>
  
  <p>Update ! Spring framework 4.2 greatly simplifies this by adding @CrossOrigin annotation to either a method or a controller itself <a href="https://spring.io/blog/2015/06/08/cors-support-in-spring-framework" rel="noreferrer">https://spring.io/blog/2015/06/08/cors-support-in-spring-framework</a></p>