views:

530

answers:

2

Hello, So I'm editing a web project that uses spring and I need to start adding some of spring's annotations. Two of the ones I need to add are @RequestBody and @RequestParam. I've been poking around a little and found this, but still don't completely understand what I'm to do with these annotations. Could anyone give me an example?

+1  A: 

There are good examples in the documentation, for both @RequestMapping and @RequestBody

skaffman
+2  A: 

Controller example:

@Controller
class FooController {
    @RequestMapping("...")
    void bar(@RequestBody String body, @RequestParam("baz") baz) {
        //method body
    }
}

@RequestBody: variable body will contain the body of the HTTP request

@RequestParam: variable baz will hold the value of request parameter baz

arjan