日期:2014-05-20 浏览次数:20634 次
//作为几个bean的形势传输! public class Test { public static void main(String[] args) { UserInfo[] user = new UserInfo[1]; user[0].setName("zhao"); ReflectClass r = new ReflectClass(); r.setMessage("hello"); r.setRecordNum(1); r.setUserInfos(user); } } class ReflectClass { private int recordNum; private String message; private UserInfo[] userInfos; public int getRecordNum() { return recordNum; } public void setRecordNum(int recordNum) { this.recordNum = recordNum; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public UserInfo[] getUserInfos() { return userInfos; } public void setUserInfos(UserInfo[] userInfos) { this.userInfos = userInfos; } } class UserInfo { private String name = null; public String getName() { return name; } public void setName(String name) { this.name = name; } }
------解决方案--------------------
//谢谢caoyinghui1986建议! import java.io.Serializable; public class Test { public static void main(String[] args) { UserInfo[] user = new UserInfo[1]; user[0].setName("zhao"); ReflectClass r = new ReflectClass(); r.setMessage("hello"); r.setRecordNum(1); r.setUserInfos(user); } } class ReflectClass implements Serializable { private int recordNum; private String message; private UserInfo[] userInfos; public int getRecordNum() { return recordNum; } public void setRecordNum(int recordNum) { this.recordNum = recordNum; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public UserInfo[] getUserInfos() { return userInfos; } public void setUserInfos(UserInfo[] userInfos) { this.userInfos = userInfos; } } class UserInfo implements Serializable { private String name = null; public String getName() { return name; } public void setName(String name) { this.name = name; } }