hi, I'm puzzled with annotating method formal parameters. I understand annotating classes and methods themselves.
Client using/calling those classes can use reflection to find out which "flags" have been set to the inspected class. I also understand it for methods (like Springs @Transactional). But I can't seem understand the usage for method parameters, for example @PathVariable with Spring mvc. I already tried to search answers from this site and from google, but answers are more like "how", instead of "why"..
Knowing the good folks here, could someone enlighten me? Please, give some simple examples where (and why) to annotate method parameters, also some code example from the client calling that method would be great..
Not sure, which part isn't clear. For e.g. consider the PathVariable documentation in the spring doc, the part in bold below talks about where and why its used ...
To access parts of a request URL in your handling methods, use the URI templates in the @RequestMapping path value.
Use the @PathVariable method parameter annotation to indicate that a method parameter should be bound to the value of a URI template variable.