Spring 3 MVC : problem with form:errors and bindingresult
- by Maxime ARNSTAMM
Hi,
I want to validate my inputs but i can't make it work : nothing appear on the page.
My project is in java 5, so no JSR303 (@Valid). My only solution, if i'm not mistaken, is to use BindingResult.
My controller :
@Controller
public class MyController {
@RequestMapping(method = RequestMethod.POST, value = "myPage.html")
public void myHandler(MyForm myForm, BindingResult result, Model model) {
result.reject("field1", "error message 1");
}
}
My jsp :
<form:form commandName="myForm" method="post">
<label>Field 1 : </label>
<form:input path="field1" />
<form:errors path="field1" />
<input type="submit" value="Post" />
</form:form>
What am i missing ?
Thanks !