Browsing through the source of a spring framework project i came across a method that looked like this:
@RequestMapping("primitive")
public @ResponseBody String primitive(@RequestParam Integer value) {
return "Converted primitive " + value;
}
Being only a casual java user, ive not come across this before. As far as i was aware, the @ symbol preceded java annotations, yet there appear to be annotations in the method signature itself. What are the @ResponseBody and @RequestParam sections doing?
The @ResponseBody is actually just a Plain-Jane Method annotation. You're allowed to put them after the scope keyword.
The @RequestParam annotation isn't part of the method signature. It's a Parameter Annotation.
Those annotations are specific to Spring, so you'll need to dive into Spring to learn all the annotations and what they mean.
Whenever I need to learn something new in Spring, I always jump back to the documentation: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/
It's good to read through that whole thing at least once in your life, if you plan on using Spring for enterprise development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With