我试图将客户端bean传递给genericResponsor类。但它无法检索bean值。
主要课程
public Response searchClient(String json){
//construct the receiver
GenericReceiver<ClientBean> receiver = new GenericReceiver<ClientBean>();
ClientBean clientbean = receiver.BeanReceiver(json, ClientBean.class);
HeaderBean headerbean = receiver.HeaderReceiver(json);
//process the data
ClientBean[] list = clientdao.searchclient(clientbean);
//construct the responser
GenericResponser<ClientBean> responser = new GenericResponser<ClientBean>();
String Jsonbody = responsor.JsonResponse(clientbean, list, headerbean);
}
GenericResponser类它似乎有问题来检索clientBean.getCompanyId
public class GenericResponser <T>{
public String JsonResponse( T bean,T[] list, HeaderBean headerbean) {
String responsejson = ("{\"companyID\":\"" + bean.getCompanyId() + "\"}");
}
}
在调试期间,我能够在GenericResponser中看到clientbean的所有值,但是无法使用并获取值。请帮助获取clientbean的值。
ClientBean类
public class ClientBean {
private String companyId;
private String branchId;
public ClientBean () {
super();
this.companyId = "";
this.branchId = "";
}
public java.lang.String getCompanyId() {
return FormUtil.returnString(companyId);
}
public java.lang.String getBranchId() {
return FormUtil.returnString(branchId);
}
public void setCompanyId(java.lang.String newCompanyId) {
companyId = FormUtil.returnString(newCompanyId);
}
public void setBranchId(java.lang.String newBranchId) {
branchId = FormUtil.returnString(newBranchId);
}
}
我这样做的目的是Generic,因为它可能会将其他bean传递给GenericResponser。