Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 866
Kevin Avatar asked Dec 28 '25 23:12

Kevin


1 Answers

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

like image 174
Bozho Avatar answered Dec 30 '25 12:12

Bozho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!