BeanUtil中map和对象的转换

将对象所有的值转换为string装入map,自定义话

        Map<String, Object> map = BeanUtil.beanToMap(userDTO,new HashMap<>(),
                CopyOptions.create().setIgnoreNullValue(true).setFieldValueEditor((fieldName,fieldValue)->{
                    return fieldValue.toString();
                }));

将map转换为对象

        UserDTO userDTO = BeanUtil.fillBeanWithMap(entries, new UserDTO(), false);

 

posted @ 2024-05-30 10:06  凉忆~  阅读(229)  评论(0)    收藏  举报