@Controller
public class TestBinderController {
@InitBinder("account")
public void initBinder1(WebDataBinder binder) {
binder.setFieldDefaultPrefix("acc.");
}
@InitBinder("user")
public void initBinder2(WebDataBinder binder) {
binder.setFieldDefaultPrefix("user.");
}
@RequestMapping("/testInput")
public String testBinderInput(){
return "testInput";
}
@RequestMapping("/testOutput")
public void testBinderOuput(@ModelAttribute Account account,@ModelAttribute User user,BindingResult result){
System.out.println(user);
System.out.println(account);
}
}
<html>
<body>
<form action="/testOutput" method="post">
<input name="acc.loginId">
<input name="user.loginid">
<input type="submit">
</form>
</body>
</html>