I would like to know which one of the above are better/correct/most_used or what. The first, using value in the @RequestMapping or the other using path.
@RequestMapping(value = { "/isbn/{isbnCode}" }, method = RequestMethod.GET)
public ResponseEntity<?> findByIsbnCode(@PathVariable String isbnCode) {
Book obj = service.findByIsbnCode(isbnCode);
return ResponseEntity.ok().body(obj);
}
// Request: http://localhost:8080/books/title?title=book_title
@RequestMapping(method = RequestMethod.GET, path = { "/title" })
public ResponseEntity<?> findByTitle(@RequestParam(value = "title") String title) {
Book obj = service.findByTitle(title);
return ResponseEntity.ok().body(obj);
}
// Request: http://localhost:8080/books/isbn/978-84-663-4612-2
Both works. Just wanna find out the differences between the two.
Thanks in advance!