当前位置: 代码迷 >> Web前端 >> DWR 回来集合 demo
  详细解决方案

DWR 回来集合 demo

热度:896   发布时间:2012-11-23 00:03:43.0
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;
	}
  相关解决方案