Spring 3 MVC : problem with form:errors and bindingresult
Posted
by
Maxime ARNSTAMM
on Stack Overflow
See other posts from Stack Overflow
or by Maxime ARNSTAMM
Published on 2011-01-12T15:34:30Z
Indexed on
2011/01/12
15:53 UTC
Read the original article
Hit count: 243
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 !
© Stack Overflow or respective owner