automatically add header to every response

后端 未结 6 1111
抹茶落季
抹茶落季 2020-11-28 07:43

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 a

6条回答
  •  离开以前
    2020-11-28 08:07

    If you want to set headers for controller you can use @ModelAttribute annotation.

    @ModelAttribute
    public void setVaryResponseHeader(HttpServletResponse response) {
        response.setHeader("Vary", "Accept");
    }    
    

提交回复
热议问题