/**
* 2018/05/30 by suntaotao
* 使用反射机制动态调用dto的set方法根据参数 属性名 如 name 调用dto的 setName方法 完成赋值 并且返回dto
* @param dto
* @param name
* @param value
* @return
* @throws Exception
*/
public static <T> T setValue(T dto,String name,Object value){
try {
Method[] m = dto.getClass().getMethods();
for(int i=0;i<m.length;i++){
if(("set"+name).toLowerCase().equals(m[i].getName().toLowerCase())){
m[i].invoke(dto,value);
return dto;
}
}
return null;
} catch (Exception e){
throw new ServiceException("调用反射进行set失败");
}
}