import com.onway.OrderSaveReqVO; import java.lang.reflect.Field; /** * 描述: */ public class Test { public static void main(String[] args) { OrderSaveReqVO reqVO = new OrderSaveReqVO(); reqVO.setFphm(1); Field[] fields = reqVO.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); //获取字段名称 String name = field.getName(); Object value = null; try { //获取字段值 value = field.get(reqVO); } catch (IllegalAccessException e) { e.printStackTrace(); } if (value != null) { System.out.println("字段名称:" + name + ",字段值:" + value); } } } }