ServletRequestDataBinder的作用

来源:互联网 发布:苹果cms展示不会显示 编辑:程序博客网 时间:2024/06/10 07:14

ServletRequestDataBinder的作用应该是把前台页面表单中的字段,直接到后台封装成一个对象,例:

PaidInRecordReportDTO paidInRecordReportDTO = new PaidInRecordReportDTO();//这是一个实体类

ServletRequestDataBinder businessProofListinder = new ServletRequestDataBinder(paidInRecordReportDTO);
businessProofListinder.bind(request);//这样就映射成一个对象

前台页面:

 <input name="auditingCode" id="auditingCode" style="width: 150px;">

  <input name="contractCode" id="contractCode" style="width: 150px;">

........

页面的name属性完全对应着PaidInRecordReportDTO 实体类中的属性(名字和类型),若类型或者名字有一样不对应它不会报错只是不会绑定此属性而已。不像springMvc在方法上直接接收对象一旦类型不对,就会报错。


0 0