/** * MethodName : getReflection <br> * 설명 : 解析 respxml 在通过反射设置对象属性值 * 사용자 : Liqijing * 날짜 : 2015-7-19 下午 12:42:55 * @param clzzname * @param respxml * @return * @throws classnotfoundexception * @throws * @throwss ELEGALEGOMUTENCEMPENTion * @Throws 불법 행위 exception * @Throws InstantiationException * @throws securityException * @throws nosuchfieldException */public static getReflection (String ClzzName, String RESPXML)은 classNotFoundException, DocumentException, INGOLEGOLATICECTECTion, InstantiCeCeption, NOSUCHIEDECTION, NOSUCHIEDECTION, NOSUCHIEDECTION, NOSUCHILECTE class.forname (clzzname) .newinstance (); clz clz = class.forname (clzzname) .newinstance (). getClass (); document doc = null; doc = docileghelper.parsetext (respxml); element el = doc.getRootElement (); for (field f : clz.getDeclaredfields (field f : clz.getDeclaredfields)). it = el.elementiterator (); while (it.hasnext ()) {element elt = (element) it.next (); if (f.getName (). equals (elt.getName ()) {f = clz.getDecLaredfield (elt.getName ()); f.setAccessible (f.setAccessible (o, f.setAccessible); elt.getText ());}}} return o;}여러분 모두에게:
在开发过程中有类似的需求通过反射动态设置属性值 在开发过程中有类似的需求通过反射动态设置属性值, 希望有帮助。也很高兴与大家分享, 谢谢。
以上这篇 Java a a, 希望能给大家一个参考, 也希望大家多多支持武林网。