写一个函数使用反射实现通过javaBean的属性名获取属性值
解决方案 »
- UML中有哪些静态图?那些动态图?
- spring 连接数据库
- 怎么把Set对象的元素取出来?
- WEBLOGIC,HPUNIX, 正常启动,但停止时报错. Exception in thread "main" java.net.UnknownHostException
- ActionForm只能在web.xml配置吗?
- 初学java都会遇到的问题
- 要做O/R Mapping方面的毕业设计,希望大家给点建议!谢谢!
- 用过Struts翻页的朋友请进。
- 把HelloAppClient.jar部署到另一台机器
- 各位高手指点返回collection后的实体bean如何按字段排序!急
- 文思智力面试题2
- 自定义标签处理类问题
package org.apache.easframework.core.entity.impl;import java.lang.reflect.Field; public class TestEntity {
private String code;
private String name;
public void setCode(String code)
{
this.code = code;
}
public String getCode()
{
return this.code;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return this.name;
}
public static void main(String[] args) throws SecurityException, ClassNotFoundException, IllegalArgumentException, IllegalAccessException
{
TestEntity obj = new TestEntity();
obj.setName("name value");
obj.setCode("code value");
Field[] fds = Class.forName("org.apache.easframework.core.entity.impl.TestEntity").getDeclaredFields();
System.out.println(fds.length);
for(int i=0;i<fds.length;i++)
{
System.out.println(fds[i].get(obj));
}
}}