Reputation: 11486
I have the following @RequestMapping
within my Spring MVC controller:
@RequestMapping(value = "{personId}/rtbc-{personId}-badge.pdf", method = RequestMethod.GET)
public ModelAndView produceBadgePdf(@PathVariable Integer personId){
// rest of the code
}
My question is: How can I ensure that the two personId
s in the @RequestMapping
are matching Integers? Should I just make the variable names differ? Or could I keep the variable names the same?
Upvotes: 2
Views: 393
Reputation: 20063
I would change these to seperate integers so you can compare them and end up with the below. Given your example above this should cause no problems and you wouldn't need to edit any client side code of the request either.
@RequestMapping(value = "{personId}/rbc-{secondPersonId}-badge.pdf", method = RequestMethod.GET)
public ModelAndView produceBadgePdf(@PathVariable Integer personId, @PathVariable Integer secondPersonId){
if(secondPersonId !=null && secondPersonId.equals(personId)) { }
}
Upvotes: 4