How to use BeanUtils.copyProperties?

前端 未结 3 1660
臣服心动
臣服心动 2020-12-24 08:14

I am trying to copy properties from one bean to another. Here are the signature of two beans:

SearchContent:

public cla         


        
3条回答
  •  执笔经年
    2020-12-24 08:46

    If you want to copy from searchContent to content, then code should be as follows

    BeanUtils.copyProperties(content, searchContent);
    

    You need to reverse the parameters as above in your code.

    From API,

    public static void copyProperties(Object dest, Object orig)
                               throws IllegalAccessException,
                                      InvocationTargetException)
    

    Parameters:

    dest - Destination bean whose properties are modified

    orig - Origin bean whose properties are retrieved

提交回复
热议问题