主要是這段java
for (java.lang.reflect.Method m : parameter.getClass().getDeclaredMethods()) { String methodname = m.getName(); //取方法的名字 Object[] agrs = new Object[]{}; String methodvalue; methodvalue = String.valueOf(m.invoke(parameter,agrs)); //取對象的值 }
原代碼:加密
ArrayList<String> codelist = new ArrayList<String>(); /**加密方案**/ String ignoreMethod = "getSecurityCode|getGeQuoteMainJson|getSaleStep|getBackflag"; for (java.lang.reflect.Method m : parameter.getClass().getDeclaredMethods()) { String methodname = m.getName(); if (methodname.startsWith("get") && !ignoreMethod.contains(methodname)) { logger.debug("m.getName():"+m.getName()); try { Object[] agrs = new Object[]{}; String methodvalue; methodvalue = String.valueOf(m.invoke(parameter,agrs)); if(StringUtils.isNotEmpty(methodvalue) && !methodvalue.equals(null) && methodvalue != "null"){ logger.debug("m.getName():"+m.getName()+" methodvalue:"+methodvalue); codelist.add(methodvalue); } } catch (InvocationTargetException e) { logger.error(((InvocationTargetException) e).getTargetException()); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } //end if }//end for