开发者

spring RequestHeader annotation on model object?

开发者 https://www.devze.com 2023-02-19 09:06 出处:网络
Can I put @RequestHeader on a model object property? I.e. class MyModel { String ua; public void setUa(@RequestHeader开发者_运维百科(\"User-Agent\") String ua) {

Can I put @RequestHeader on a model object property? I.e.

class MyModel {
    String ua;
    public void setUa(@RequestHeader开发者_运维百科("User-Agent") String ua) {
        this.ua = ua;
    }
}

This works with @RequestParam, but seems to have no effect when I use @RequestHeader. Am I missing something? And, if this isn't supported, is there some reason why?


You can do this only in controller methods. Not model objects. Check the documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消