后台返回的List<E>数据如何让前台ComboBox显示
后台javaaction代码publicStringexecute(){SexServicesexService=SexServiceFactory.getSexServ...
后台java action代码
public String execute(){
SexService sexService = SexServiceFactory.getSexService();
List<Xtwh_Sex> sexList = sexService.showSex();
return "SUCCESS";
}
如何将sexList传递至 Extjs 中ComboBox组件中
前台接收数据的store为
var sexStore = new Ext.data.Store(
{
proxy : new Ext.data.HttpProxy(
{
url : 'showSexAction.action'
}),
reader : new Ext.data.ArrayReader(
{},
[
{
name : 'id'
},
{
name : 'value'
} ])
});
sexStore.load();
请问之间如何传递 展开
public String execute(){
SexService sexService = SexServiceFactory.getSexService();
List<Xtwh_Sex> sexList = sexService.showSex();
return "SUCCESS";
}
如何将sexList传递至 Extjs 中ComboBox组件中
前台接收数据的store为
var sexStore = new Ext.data.Store(
{
proxy : new Ext.data.HttpProxy(
{
url : 'showSexAction.action'
}),
reader : new Ext.data.ArrayReader(
{},
[
{
name : 'id'
},
{
name : 'value'
} ])
});
sexStore.load();
请问之间如何传递 展开
1个回答
展开全部
public String execute(){
SexService sexService = SexServiceFactory.getSexService();
List<Xtwh_Sex> sexList = sexService.showSex();
StringBuilder sb = new StringBuilder();//构造json
sb.append("[");
if(sexList.size()>0)
{
for(Xtwh_Sex sex:sexList)//遍历 sexList
{
sb.append("{\"id\": \"" + sex.getId() //对应store里面id属性
+ "\",\"name\": \"" + sex.getName()+"\ " //对应store里面id属性
}
}
return sb;
}
获取到的json数据如下:{id:"xxx",name:"xxxx"}
SexService sexService = SexServiceFactory.getSexService();
List<Xtwh_Sex> sexList = sexService.showSex();
StringBuilder sb = new StringBuilder();//构造json
sb.append("[");
if(sexList.size()>0)
{
for(Xtwh_Sex sex:sexList)//遍历 sexList
{
sb.append("{\"id\": \"" + sex.getId() //对应store里面id属性
+ "\",\"name\": \"" + sex.getName()+"\ " //对应store里面id属性
}
}
return sb;
}
获取到的json数据如下:{id:"xxx",name:"xxxx"}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询