Here is my Controller code:
@RequestMapping(value = "/accountholders/{cardHolderId}/cards/{cardId}", produces = "application/json; charset=utf-8", consumes = "application/json", method = RequestMethod.PUT)
@ResponseBody
public CardVO putCard(@PathVariable("cardHolderId") final String cardHolderId,
@PathVariable("cardId") final String cardId, @Valid @RequestBody final RequestVO requestVO,
@RequestParam final Map<String, String> allRequestParams) {
iCardService.updateCardInfo(cardId, requestVO.getActive());
return iCardService.getCardHolderCardInfo(cardHolderId, cardId);
}
THis is my Request Bean:-
public class RequestVO {
@NotNull
private Boolean active;
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
My request Body:-
{
"active":true,
"abc":"ignoring this"
}
The problem I am having is when i sent an extra parameter in the request Body It seems to ignore the extra value in this case "abc". The code works and give me the response What I need to throw is 400 BAD REQUEST.
Am i missing something or is their a way to tell it to throw an exception when an extra parameter is passed.