For some reason I cannot seem to fix this issue, even after looking at multiple examples on here.
I am trying to handle a form using Spring 3 MVC, but I am getting t
Try to add @ModelAttribute("reverseString")
in your onSubmit method's parameters.
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, @ModelAttribute("reverseString") ReverseString revString, BindException errors)
throws Exception
For me this error was resolved by declaring
@ModelAttribute("person")
public Person createFormModelAttribute() {
return new Person();
}
in the controller. And also on the jsp, I refer to the model attributes by referencing the class name:
<form:input path="person.firstName" />
In your reverse.jsp file, you added modelAttribute as reverseString. So while before loading reverse.jsp, it will look for your ReverseString.java object.
You just need to add ReverseString.java object in request scope of your controller method from where you navigate user to reverse.jsp.
e.g.
@RequestMapping(value = "/getReverseStringForm")
public String cmLogin(Model model) {
model.addAttribute(new ReverseString());
return "reverse";
}
As I have found out for my self this exception most of cases appears when path to the controller is wrong. Or mistake in syntax. So very carefully check if all links in jsp and paths are right. Because even '/' can be reason of exception.