I have a bean to validate using jsr-303 but the BIndingResult returns no error. every time it returns to the success view
My Bean is
public class User
{
//@NotNull
private int userId;
@NotNull
@Size(min=3,max=100)
private String userName;
@NotNull
@Size(max=60)
private String userFullName;
}
my controller is
@RequestMapping(value="/user")
@Controller
public class UserController{
@RequestMapping(value="/create",method=RequestMethod.GET)
public String createUserForm(Map model)
{
model.put("user",new User());
return "createUserForm";
}
@RequestMapping(value="/create",method=RequestMethod.POST)
public String createUser (@Valid @ModelAttribute("user") User user,BindingResult result,Map model)
{
if(result.hasErrors())
{
return "createRmsUserForm";
}
else
{
model.put("User",user);
return "redirect:/home";
}
}
}
dispatcher-servlet.xml.<mvc:annotation-driven />is the easiest way.