DWR 返回集合 demo
配置参考前几篇DWR demo
<script type="text/javascript" src="<%=path %>/dwrjs/util.js"></script>
<script type="text/javascript" src="<%=path %>/dwrjs/engine.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/dwr/interface/testDwrService.js"></script>
<script type="text/javascript">
function showSelect(){
testDwrService.returnList(function(data){
alert(data);
for(var i in data){
var bean = data[i];
alert(bean.userName+' '+bean.psw);
}
});
}
</script>
<allow>
<create creator="new" javascript="testDwrService">
<param name="class" value="com.dwr.TestDwrService2" />
<include method="returnList" />
</create>
<convert converter="bean" match="com.dwr.UserBean">
<param name="include" value="id,userName,psw"></param>
</convert>
</allow>
// dwr 返回集合
public List<UserBean> returnList(){
System.out.println("returnList ....04");
List<UserBean> list = new ArrayList<UserBean>();
for(int i=0;i<5;i++){
UserBean user = new UserBean();
user.setUserName("userName"+i);
user.setPsw("psw"+i);
list.add(user);
}
return list;
}