Monday 23 November 2015

Spring @RequestParam vs @PathVariable


Assume this Url for the below code : http://localhost:8080/MyApp/user/1234/invoices?date=12-05-2013 (to get the invoices for userId 1234 for today)

@RequestMapping(value="/user/{userId}/invoices", method = RequestMethod.GET)
public List<Invoice> listUsersInvoices(
            @PathVariable("userId") int userId,
            @RequestParam(value = "date", required = false) Date dateValue) {

//userId value is 1234
//dateValue value is 12-05-2013

  ...
}
 
 

No comments:

Post a Comment