form表单封装数据的方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38497634/article/details/85223215

1.org.springframework.beans.BeanUtils;

spring框架自带方法

将表单数据利用 ModelDriven进行封装为类A(source),

再将数据转化为domain中的类B

BeanUtils.copyProperties(source,target);

 

2.cn.itcast.commons.CommonUtils;

需要导入itcast-tools-1.4.2.jar

User form = CommonUtils.toBean(request.getParameterMap(), User.class);

将数据封装到domain的User属性中

猜你喜欢

转载自blog.csdn.net/qq_38497634/article/details/85223215