转载自:https://blog.csdn.net/weixin_45514077/article/details/108197864
public static void converNullToString(Object object) throws RuntimeException{ try{ Field[] fs =object.getClass().getDeclaredFields(); for(int i=0;i<fs.length;i++){ Field f = fs[i]; f.setAccessible(true); Object val = f.get(object); String type = f.getType().toString(); if(type.endsWith("String")){ if("" != val && null ==val){ f.set(object,"/"); } } } }catch (Exception e){ throw new RuntimeException(String.format("converNullToString fail ->{}",e.getMessage())); } }