Debug HTTP 400 errors in Spring MVC

If your JSON and Java classes don’t match, Spring MVC will return a 400 Bad Request without telling you why. You can get a better insight at what’s going wrong by adding an exception handler in the controller.

@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)
public void handle(Exception e) {
    log.warn("Returning HTTP 400 Bad Request", e);
}