hutool实现map转DTO
所属分类 hutool
浏览量 7
map转dto ,大小写 下划线 驼峰自动转换
public class UserDTO {
private Long userId;
private String userName;
private Boolean active;
private java.util.Date createTime;
// get setter
}
Map< String, Object> map = new HashMap< >();
map.put("user_id", 1001L);
map.put("USER_NAME", "张三");
map.put("active", true);
map.put("create_time", new Date());
UserDTO dto = new UserDTO();;
BeanUtil.fillBeanWithMap(map,dto,false);
dto = BeanUtil.toBean(map,UserDTO.class);
dto = new UserDTO();
BeanUtil.copyProperties(map, dto);
// bean转map
Map< String, Object> map2 = BeanUtil.beanToMap(dto);
上一篇
Docker & Docker Compose 常用命令速查表
《人类简史》 历史年表
Hutool 字符串占位符