jabsorb笔记_几个小例子第1/2页
研究了一下 jabsorb,写了几个简单的例子,希望能够帮助菜鸟快速入门。
首先引用jabsorb-1.2.2.jar,slf4j-api-1.4.2.jar,slf4j-jdk14-1.4.2.jar,jsonrpc.js
类文件:
package com.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TestJabsorb {
public String getMessage(String s) {
return "你好: " + s;
}
public String getMessage() {
return "无参数";
}
public String getMessage(List al) {
String res="list参数:";
for(Iterator it = al.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(String[] array) {
String res="数组参数:";
for(int i=0;i<array.length;i++){
res+=array[i]+",";
}
return res;
}
public String getMessage(Map map) {
String res="map参数:";
Set entrySet = map.entrySet();
for(Iterator it = entrySet.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(Test2 t2) {
String res="Test2(bean)参数:";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public String getMessage(Test3 t2) {
String res="Test3(bean)参数:";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public Test2 getMessage2() {
Test2 res=new Test2();
res.p1="11";
res.p2="22";
return res;
}
public Test3 getMessage3() {
Test3 res=new Test3();
res.p1="11";
res.p2="22";
return res;
}
public List getList()
{
List list = new LinkedList();
list.add("中国");
list.add(1234);
return list;
}
public Map getMap()
{
Map map = new HashMap();
map.put("bird", "鸟");
map.put("human", "人类");
return map;
}
}
package com.test;
public class Test2{
public String p1;
public String p2;
public String getP1() {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public String getP2() {
return p2;
}
public void setP2(String p2) {
this.p2 = p2;
}
}
首先引用jabsorb-1.2.2.jar,slf4j-api-1.4.2.jar,slf4j-jdk14-1.4.2.jar,jsonrpc.js
类文件:
package com.test;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TestJabsorb {
public String getMessage(String s) {
return "你好: " + s;
}
public String getMessage() {
return "无参数";
}
public String getMessage(List al) {
String res="list参数:";
for(Iterator it = al.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(String[] array) {
String res="数组参数:";
for(int i=0;i<array.length;i++){
res+=array[i]+",";
}
return res;
}
public String getMessage(Map map) {
String res="map参数:";
Set entrySet = map.entrySet();
for(Iterator it = entrySet.iterator();it.hasNext();){
Object next = it.next();
res+=next+",";
}
return res;
}
public String getMessage(Test2 t2) {
String res="Test2(bean)参数:";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public String getMessage(Test3 t2) {
String res="Test3(bean)参数:";
res+=t2.p1+",";
res+=t2.p2+",";
return res;
}
public Test2 getMessage2() {
Test2 res=new Test2();
res.p1="11";
res.p2="22";
return res;
}
public Test3 getMessage3() {
Test3 res=new Test3();
res.p1="11";
res.p2="22";
return res;
}
public List getList()
{
List list = new LinkedList();
list.add("中国");
list.add(1234);
return list;
}
public Map getMap()
{
Map map = new HashMap();
map.put("bird", "鸟");
map.put("human", "人类");
return map;
}
}
package com.test;
public class Test2{
public String p1;
public String p2;
public String getP1() {
return p1;
}
public void setP1(String p1) {
this.p1 = p1;
}
public String getP2() {
return p2;
}
public void setP2(String p2) {
this.p2 = p2;
}
}
JS 创建对象(常见的几种方法)
贴个代码先:functionO(user,pwd){//useconstructorthis.user=user;this.pwd=pwd;this.get=get;returnthis;}functionO2(user,pwd){//usefactoryvarobj=newObject();obj.user=user;obj.pwd=pwd;obj.get=get;retur
JS 继承实例分析
functionP(name){this.name=name;this.p1=function(){alert('ParentConstructor');}returnthis;}functionC(name,id){//this.method=P;//this.method(name);//1stmethod//P.call(this,name);//2ndmethodP.apply(this,
Javascript 对象的解释
所有的构造器都是对象,而并非所有的对象都是构造器.每个构造器都有一个用来实现原型继承、共享属性的Prototype属性。对象通过new表达式创建;比如