I have a Spring Controller class set up with @RequestMapping("/vehicle") set at the class level. One method of this class is
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public Vehicle getVehicleByRegistration(
@RequestParam(value="doAs", required = true) String doAsUser,
@RequestParam(value="registration", required = true) String registration) throws IOException {
return vehicleController.getByIndex(registration, doAsUser);
}
and I'm sending queries to it like:
curl -iv localhost:8096/vehicle/?doAs=user®istration=ABC1234
When executed, I get a response containing:
"exception":"org.springframework.web.bind.MissingServletRequestParameterException","message":"Required String parameter 'registration' is not present"
If I reverse the order of doAs and registration in the URL then the error says that 'doAs' is not present.
If I modify the method to only take one argument (either doAs or registration) then it works fine.
What's going wrong here? I've tried using param in the @RequestMapping but that doesn't work either.