通过反射获取对象属性

user类

@Data
public class User {
    private Integer age;

    private String name;

    private String password;

}

反射获取

        //获取参数对象
        String age = PropertyUtils.getProperty(user,"age").toString();
        String name = PropertyUtils.getProperty(user,"name").toString();
        String password = PropertyUtils.getProperty(user,"password").toString();
        System.out.println("===========" + age);
        System.out.println("===========" + name);
        System.out.println("===========" + password);

你可能感兴趣的:(工具栏)