how to set header no cache in spring mvc 3 by annotation

后端 未结 3 666
借酒劲吻你
借酒劲吻你 2020-11-30 23:13

how to set header no cache in spring mvc 3 by annotation? not is

  response.setHeader(\"Pragma\",\"No-cache\");     
  response.setHeader(\"Cache-Control\",         


        
3条回答
  •  天命终不由人
    2020-11-30 23:28

    There is no such option. You can use an interceptor:

    
    
        
            
            
            
            
        
    
    

    (taken from here)

    On one hand it is logical not to have such annotation. Annotations on spring-mvc methods are primarily to let the container decide which method to invoke (limiting it by a request header, request url, or method). Controlling the response does not fall into this category.

    On the other hand - yes, it will be handy to have these, because when controllers are unit-tested it is not relevant to test http header stuff (or is it?). And there are @ResponseBody and @ResponseStatus, which do specify some response properties.

提交回复
热议问题