The incoming request from the user may support HTTP methods such as get, post, put, and delete. Spring 4.3 has added the following as composed variants to handle the HTTP methods:
- @GetMapping
- @PostMapping
- @PutMapping
- @PathMapping
- @DeleteMapping
Let's demonstrate @GetMapping for our searchBookByAuthor() methods as follows:
@GetMapping (value = "searchBooks.htm") public ModelAndView searchBookByAuthor_get(@RequestParam("author")
String author_name) { // code remains same as that of searchBookByAuthor() method }
Now you understand how to read individual request parameters. Reading individual request parameters one by one, and then binding them to the object of the bean becomes clumsy and unnecessarily lengthy. A better option is provided by the framework using form-backing object.