BeanUtils.populate(object1,object2);
import org.apache.commons.beanutils.BeanUtils;
BeanUtils.populate(object1,object2);
該方法用來將object2裏的數據影射到object1裏面,
需要條件是兩個OBJECT裏的屬性一致,例如:
object1:
public class object1{
private String id;
private String name;
private String age;
}
object2:
map(id=1,name=liu,age=23)
這樣經過
BeanUtils.populate(object1,object2);
object1裏的屬性值便與object2裏的一樣了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.