From what I can tell this is set up correctly but I am getting the following error:
java.lang.IllegalStateException: Neither BindingResult nor plain target
First I had the form in index.html
@RequestMapping(value = "/", method = RequestMethod.GET)
public String indexPage(){
return "index";
}
So when my form:
Was looking for /
it was hitting the above method, NOT:
@RequestMapping(value="/", method=RequestMethod.GET)
public String contactForm(@Valid @ModelAttribute("person") Person person, BindingResult bindingResult,
HttpServletRequest request, Model model) throws IOException {
if(bindingResult.hasErrors()){
System.out.println("There was a error "+bindingResult);
return "index";
}
model.addAttribute("person", new Person());
return "index";
}
Which was correct!
I had to remove the first method and it worked.