1、public String getName()return name;HelloDwr.javaimport java.util.List;import java.util.ArrayList;import java.util.Map;import java.util.HashMap;public class HelloDwr public String hello(String name) return name + ,您好!您已经开始了DWR的学习之旅,祝您学得开心.; public String sendObj(Person p ) return p.getName() + 您已经学会了
2、使用JavaBean参数. public Person getBean(String name) return new Person(服务器端 + name); public Cat getObject(String name) return new Cat( public List getPersonList() List result = new ArrayList(); result.add(new Person(集合aaaa);集合bbbb集合cccc return result; public Person getPersonArray() Person result = new P
3、erson3; result0 = new Person(数组aaaa); result1 = new Person(数组bbbb result2 = new Person(数组cccc public Map getPersonMap() Map result = new HashMap result.put(first , new Person(Map aaaasecondMap bbbthirdMap cccc public String sendList(List pl) String result = for (Person p : result += p.getName() + pu
4、blic String sendMap(Map pmap) for (String key : pmap.keySet() result += 键 + key + 其值为: + pmap.get(key).getName() + public class HelloDwrpublic String hello(String name)return name + public String sendObj(Person p )return p.getName() + public Person getBean(String name)return new Person(public Cat ge
5、tObject(String name)return new Cat(public List getPersonList()Listresult.add(new Person(return result;public Person getPersonArray()Person result = new Person3;result0 = new Person(result1 = new Person(result2 = new Person(public Map getPersonMap()Mapresult.put(public String sendList(List pl)String
6、result = for (Person p :public String sendMap(Maphellodwr.jsJs代码 /-发送简单字符串参数,返回普通字符串-function sendMessage() var name = document.getElementById(name).value; hello.hello(name , cb)function cb(data) document.getElementById(show).innerHTML = data;/-发送一个JavaBean对象作为参数,返回普通字符串-function sendObject() var na
7、meValue = document.getElementById( hello.sendObj(name:nameValue , cb);/-调用返回JavaBean方法-function getBean() hello.getBean(name , beanCb)function beanCb(data).innerHTML = data.name + ,您好,您已经学会了使用JavaBean返回值/-调用返回getObject方法-function getObject() hello.getObject(name , objCb)function objCb(data),是从服务器返回的
8、猫的名字/-调用返回集合的方法-function getBeanList() hello.getPersonList(listCb);function listCb(data) var result= for (var i = 0 ; i data.length ; i +) result += datai.name + ).innerHTML = result;/-调用返回数组的方法-function getBeanArray() hello.getPersonArray(arrayCb);function arrayCb(data)function getBeanMap() hello.g
9、etPersonMap(mapCb);function mapCb(data) for (var key in data)键为,其值为: + datakey.name + /-调用发送集合的方法-function sendBeanList() var args = name:客户端aaa,客户端bbb客户端ccc ; hello.sendList(args , sendListCb);function sendListCb(data)/-调用发送Map的方法-function sendBeanMap() var args = first:name: second: third: ; hello
10、.sendMap(args , sendMapCb);function sendMapCb(data)/-发送简单字符串参数,返回普通字符串-function sendMessage()var name = document.getElementById(hello.hello(name , cb)function cb(data)document.getElementById(/-发送一个JavaBean对象作为参数,返回普通字符串-function sendObject()var nameValue = document.getElementById(hello.sendObj(name:
11、/-调用返回JavaBean方法-function getBean()hello.getBean(name , beanCb)function beanCb(data) /-调用返回getObject方法-function getObject()hello.getObject(name , objCb)function objCb(data)/-调用返回集合的方法-function getBeanList()hello.getPersonList(listCb);function listCb(data)var result=for (var i = 0 ; i +)result += dat
12、ai.name + /-调用返回数组的方法-function getBeanArray()hello.getPersonArray(arrayCb);function arrayCb(data)function getBeanMap()hello.getPersonMap(mapCb);function mapCb(data)for (var key in data)result += /-调用发送集合的方法-function sendBeanList()var args = ,;hello.sendList(args , sendListCb);function sendListCb(data)/-调用
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1