用法一:
在import org.springframework.beans.BeanUtils;包下:
<span style="white-space:pre"> </span>//赋值vo对象的值到po中
<span style="white-space:pre"> </span>/**
<span style="white-space:pre"> </span>* <span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#ff0000;">BeanUtils.copyProperties(source, target);</span> 这是文档提示!</span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"> </span> * <span style="color:#ff0000;">VO对象,PO对象</span></span>
<span style="white-space:pre"> </span>*/ <span style="font-family: Arial, Helvetica, sans-serif;">BeanUtils.copyProperties(this.getModel(),sysUserGroup);</span>
//BeanUtils.copyProperties(SysUserGroupForm(vo对象), sysUserGroup(po对象); 切记用法二:
在import org.apache.commons.beanutils.BeanUtils;包下:
<span style="white-space:pre"> </span>//VO--->PO
<span style="white-space:pre"> </span>/**
<span style="white-space:pre"> </span>* <span style="font-family: Arial, Helvetica, sans-serif;"><span style="color:#cc0000;">BeanUtils.copyProperties(dest, orig); </span>这是文档提示!</span>
<span style="white-space:pre"> </span>*<span style="white-space:pre"> </span> <span style="color:#ff0000;"> PO对象,VO对象</span>
<span style="white-space:pre"> </span>*/
BeanUtils.copyProperties(sysUser, sysUserForm);另外:
在项目中,时间转换可以这样:
属于:import org.apache.commons.lang.time.DateFormatUtils;包下:
String curDate = DateFormatUtils.format(new java.util.Date(), "yyyy-MM-dd HH:mm:ss");
总结:
用方法的时候,一定要注意包!