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
@ResponseBodyis actually just a Plain-Jane Method annotation. You’re allowed to put them after the scope keyword.The
@RequestParamannotation isn’t part of the method signature. It’s a Parameter Annotation.