alibaba / tamper

A Java Bean to Java Bean mapper that recursively copies data from one object to another
http://github.com/alibaba/tamper
Apache License 2.0
247 stars 113 forks source link

请问把属性向上升级怎么做? #1

Closed sandwich99 closed 10 years ago

sandwich99 commented 10 years ago
public class User{
    private String name;
    private String age;
    private Address address;

    setter ..getter
}

public class Address{
    private Long id;
    private String location;
    private String street;
    private String houseNumber;
    private String otherAttr;

}
public class UserVO{
    private String name;
    private String age;
    private String street;
    private String location;
    private String houseNumber;

}

业务场景:

User 表有 address 属性,类型为Address 前台使用REST接口输出数据,需要把Address中的一个或多个数据向上作为UserVO的属性传递到前台表格展现。

agapple commented 10 years ago

使用EL表达式功能

比如:field-mapping targetName="street" script="src.address.street" 将左边address.street的属性,复制到右边的street属性