您的位置:首页 > 编程语言 > Java开发

springMVC准确定位多个参数对象的属性

2013-12-17 17:45 155 查看
servlet类:

@Controller
public class MyController01 {

@InitBinder("customer")
public void initBinder1(WebDataBinder binder){
binder.setFieldDefaultPrefix("customer.");
}
@InitBinder("user")
public void initBinder2(WebDataBinder binder){
binder.setFieldDefaultPrefix("user.");
}

@RequestMapping(value = "/test.do", method = RequestMethod.POST)
public ModelAndView firstTest(Customer customer, User user) {

System.out.println(user == null ? null : "  " + user.getPassword());
System.out.println("成功到达服务器! username: " + customer.getUsername()
+ " password:" + customer.getPassword());
return null;
}

}


jsp页面:

<form action="test.do" method="post"  name="login">
<span>username:</span>
<input type="text" name="customer.username">
<br />
<span>password:</span>
<input type="password" name="user.password">
<input type="submit" value="commit">
</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐