开发者

spring RequestHeader annotation on model object?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜