Question

When I add the @validate annotaion to a method signature in my controller, I get a HTTP 400 with the description, "The request sent by the client was syntactically incorrect ().". Does anyone have an idea why?

Good Code

public ModelAndView startAccountSubmittal(
    AccountCredential accountCred, HttpServletResponse response) 
       throws MessagingException {

Bad Code

public ModelAndView startAccountSubmittal(
    @Validated(value={AccountStates.Submitted.class}) 
        AccountCredential accountCred, 
    HttpServletResponse response, BindingResult result) 
        throws MessagingException {

Thanks in advance, Joe

Was it helpful?

Solution

The uncaught exception I had configured was not catching the error. I added an exception handler to the controller and I was able to get the details. I had a few extra fields it was trying to validate, which contained nulls, but required values. This what caused the HTTP 400. Turning on the exception handler helped get the exception and stacktrace. I modified the code and added extra groups, then added those new groups to the object and controller. It works as planned.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top