一般我们会开发中会遇到返回用户信息的时候,不需要返回密码或者其他参数,这时候我们需要重新定义一个VO类去除不需要的参数,将原对象copy到VO类中

使用spring的BeanUtils可以实现对象的copy

语法:

BeanUtils.copyProperties(source, target);
import org.springframework.beans.BeanUtils;

SdbDbUser user =userServer.getUserInfo(toUser); UserVO userVo= new UserVO(); BeanUtils.copyProperties(user, userVo);

 

相关文章:

  • 2021-08-06
  • 2021-12-06
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2021-12-18
  • 2022-12-23
  • 2021-04-08
相关资源
相似解决方案