Adding headers to Spring controllers

做~自己de王妃 提交于 2019-12-05 15:43:35
digitaljoel

Hoping you are using Spring 3, you can look at an interceptor, then you won't have to modify all of your controllers (since you said you had many). It looks like they may already have one implemented that you can just use. Check out Bozho's answer to this question how to set header no cache in spring mvc 3 by annotation

I realize this is an old post but maybe this will help somebody. I am using spring for this example. The main thing is use the annotation for parameters.
@Controller public class HelloController {

@RequestMapping(value = "/hello.htm")
public String hello(@RequestHeader(value="User-Agent") String userAgent)

    //..
}

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!