您的位置:首页 > 其它

解析XML文档过程中对于未知类型的值的处理

2014-06-30 21:00 239 查看
在定义XML需要对系统数据初始化时,如果取到的节点是数值类型可以通过
Attribute attribute = (Attribute) a.next();
Class fc = PropertyUtils.getPropertyType(obj, attribute.getName());//得到改属性的真实类型
System.out.println(fc);
BeanUtils.setProperty(obj, attribute.getName(), fc.getConstructor(String.class).newInstance(attribute.getData()));//调用如new Integer("1")的方法进行赋值
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: