springMVC准确定位多个参数对象的属性
2013-12-17 17:45
155 查看
servlet类:
jsp页面:
@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>
相关文章推荐
- springMVC使用JQUERY提交数组接收时候报错,接收参数对象的属性为数组
- springmvc mybatis 配置一对多的关系使用 <association> 及实体类写法2Spring MVC 会按请求参数名和 POJO 属性名进行自动匹配自动为该对象填充属性值。支持
- springmvc属性编辑器和自定义参数解析器
- ###Springmvc封装复杂表单数据:表单提交多个实体类的参数【对象类型参数,自动封装】name属性值不能重复。和实体类属性名一致
- 当一个对象被当作参数传递到一个方法后,此方法可改变这个对象的属性,并可返回变化后的结果,那么这里到底是值传递还是引用传递?
- 3 手写实现SpringMVC,第三节:通过反射给属性和参数注入值
- springmvc学习笔记——传递对象作为参数(POJO)
- SpringMVC参数绑定---对象绑定
- springMVC如何获取对象参数,@ModelAttribute
- SpringMVC 中List 对象转换成Json格式 List对象中属性为NUll解决
- 对象属性用作函数的参数
- SpringMVC如何用实体对象接收参数
- springMVC中使用List和Map绑定对象作为参数的使用方法
- MyBatis拦截器:给参数对象属性赋值
- springMVC中使用List和Map绑定对象作为参数的使用方法
- Thymeleaf 之 内置对象、定义变量、URL参数及标签自定义属性
- springMVC传对象参数
- javascript获取函数名称、函数参数、对象属性名称的代码实例
- mybatis从dao传入多个参数到sqlmap时dao中要使用map或实例对象(如:user)作为参数传入, 否则报错找不到属性getter方法
- SpringMVC接收复杂集合对象(参数)代码示例