title: Springmvc interceptors makes CORS annaotion and interceptors fail to handle Cross-domain
body: <p>I have a custom interceptor in my project and I put a @CrossOrigin(origins = "*", maxAge = 3600) on my Controller .</p>
  
  <p>When I <strong><em>don't</em></strong> use the  custom interceptor, <strong><em>the @CrossOrigin works</em></strong>,</p>
  
  <p>but when I <strong><em>use</em></strong> my custom interceptor, <strong><em>@CrossOrign doesn't work</em></strong>!</p>
  
  <p>And I also try to use my <strong><em>custom CorsInterceptor</em></strong> to handle the problem, however, 
   it <strong><em>doesn't work</em></strong> too</p>
  
  <p>How should I solve the  Cross-domain problem ?</p>
  
  <p>This is my custom CorsInterceptor:</p>
  
  <pre><code>public class ProcessInterceptor implements HandlerInterceptor {
  
  @Override
  public boolean preHandle(HttpServletRequest request,
          HttpServletResponse response, Object handler) throws Exception {
      response.setHeader("Access-Control-Allow-Origin", "*");
      response.setHeader("Access-Control-Allow-Methods",
              "POST, GET, OPTIONS,PUT, HEAD, DELETE");
      response.setHeader("Access-Control-Max-Age", "3600");
      response.setHeader("Access-Control-Allow-Headers", "Content-Type");
      response.setHeader("Access-Control-Allow-Credentials", "true");
  
      return true;
  
  }
  
  @Override
  public void postHandle(HttpServletRequest request,
          HttpServletResponse response, Object handler,
          ModelAndView modelAndView) throws Exception {
      // TODO Auto-generated method stub
  
  }
  
  @Override
  public void afterCompletion(HttpServletRequest request,
          HttpServletResponse response, Object handler, Exception ex)
          throws Exception {
      // TODO Auto-generated method stub
  
  }
  </code></pre>
  
  <p>This is my mvc configuration:</p>
  
  <pre><code>&lt;mvc:interceptors&gt;
  
      &lt;mvc:interceptor&gt;
          &lt;mvc:mapping path="/**" /&gt;
          &lt;bean class="com.dorm.interceptor.ProcessInterceptor"&gt;&lt;/bean&gt;
      &lt;/mvc:interceptor&gt;
      &lt;mvc:interceptor&gt;
          &lt;mvc:mapping path="/**" /&gt;
          &lt;mvc:exclude-mapping path="/static/css/**" /&gt;
          &lt;mvc:exclude-mapping path="/user/login" /&gt;
          &lt;mvc:exclude-mapping path="/student/login" /&gt;
          &lt;mvc:exclude-mapping path="/static/fonts/**" /&gt;
          &lt;mvc:exclude-mapping path="/static/js/**" /&gt;
          &lt;mvc:exclude-mapping path="/static/img/**" /&gt;
          &lt;mvc:exclude-mapping path="/user/testsession" /&gt;
          &lt;mvc:exclude-mapping path="/swagger-ui.html" /&gt;
          &lt;mvc:exclude-mapping path="/swagger-resources/**" /&gt;
          &lt;mvc:exclude-mapping path="/webjars/**" /&gt;
          &lt;mvc:exclude-mapping path="/v2/**" /&gt;
          &lt;bean class="com.dorm.interceptor.LoginAndPermInter"&gt;&lt;/bean&gt;
      &lt;/mvc:interceptor&gt;
  
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p>The @CrossOrgin on Controller</p>
  
  <pre><code>    @CrossOrigin(origins = "*", maxAge = 3600)
      public class UserLoginController {//...}
  </code></pre>