Hello,
I have a problem using Validator in annotated controller.
I'm using controller with annotation, everything is ok but when I use a method with two ModelAttribute, the validator doesn't care about the object that I give and try to validate the last ModelAttribute of the method signature.
Here is a part of the controller :
The Contact object and the Integer come from the session :Code:@RequestMapping(value="/contact/createCompanyContact.do", method = RequestMethod.POST) public ModelAndView doCreateLawCompanyContactAction(@ModelAttribute Contact contact, @ModelAttribute Integer Id, BindingResult result, SessionStatus status) throws Exception { contactValidation.validate(contact, result); if (result.hasErrors()){ return new ModelAndView(...); } else { status.setComplete(); ... return new ModelAndView(new RedirectView(...)); } }
When I debug, Contact is correctly filled with data from the form, and the Integer has the correct value, but the Validator doesn't validate the Contact object but the Integer !!Code:@Controller @SessionAttributes(types = {Contact.class, Integer.class}) public class ContactController { ... }


Reply With Quote
