相关链接继《JavaScript高级应用与实践》之后推出的开源代码——json-rpc-for-java light AJAX framework:
作者csdn博客 | 作者新浪600多万次点击博客 | 作者网站
... [More]
作者的经典博客(通过代理才可以访问,链接中已经包含代理http://jsonrpc.blogspot.com)
支持的浏览器IE6、IE7、IE8、FireFox(×)、Opera(×)、Safari(×)、Google Chrome(×)等等
最新功能1、异步调用支持传入复合对象作为异步方法的参数,例如: rpc.XRpc.myFunc({aac002:345,kad:'good'}); Java中可以为Map或者JavaBean对象
2、增加防止对象成员变量引用自身导致的死循环递归堆栈溢出
3、增加直接访问父类属性、方法的功能
4、支持级联调用
工程svn下载地址http://json-rpc-for-java.googlecode.com/svn/trunk/
示例工程下载地址测试环境:MyEclipse、Jre1.4、tomcat 5.0 如果你要测试,可以采用相应的环境,不一定要那么高版本的环境 2.8.1example
最新当前版本下载地址JSON-RPC.jar | JsonRpcClient.js
概述json-rpc-for-java,是仅仅不到100行的javascript代码和不到10个java文件实现的超级轻量级的通过 javaScript快速调用java对象并返回任意对象的轻量级框架,并且支持级联调用,也就是说不需要额外 的JavaScript编程,就可以通过javascript调用被注册的java对象并返回java对象,如果被返回的对象 还有方法,这个在javascript中返回的java对象的变量,你还可以继续调用它的方法.....这就是这个轻 量级json-rpc-for-java的神奇之处。 当返回的是java对象List的时候,在javascript中体现为ArrayList,如果是Map,着体现为js中的 Object,其他的和java中的调用基本相同。 特殊的地方是,通过JS调用java对象方法的时候只能传入简单类型的参数,比 如:String,int,float,long等。
注意事项如果你的java服务对象返回的是Object、Bean、Map或者自定义对象,不能有属性name_、id_,这两个属性被本框架内部使用
json rpc for java的使用请从http://code.google.com/p/json-rpc-for-java/downloads/list 下载
调用未注册和配置的类方法1、 首先,被调用的类需要继承jcore.jsonrpc.common.JsonRpcObject或实现接口jcore.jsonrpc.common.face.IjsonRpcObject,并有默认的构造函数; 例如:
package test.rpc;
import jcore.jsonrpc.common.JsonRpcObject;
public class MyTestRpc extends JsonRpcObject {
/**
* 调用:rpc.getRpcObj('test.rpc.MyTestRpc').getTestMsg()
* @return
*/
public String getTestMsg()
{
return "噢,成功了!";
}
}2、 JSP的JavaScript中调用的方式,例如:alert(rpc.getRpcObj('test.rpc.MyTestRpc').getTestMsg());
或者 1、 首先,被调用的类需要继承jcore.jsonrpc.common.JsonRpcObject或实现接口jcore.jsonrpc.common.face.IjsonRpcObject,并有默认的构造函数; 例如:
package jcore.jsonrpc.rpcobj; // 必须是jcore.jsonrpc.rpcobj包下才可以免注册
import jcore.jsonrpc.common.JsonRpcObject;
public class MyTestRpc extends JsonRpcObject {
/** 直接使用类名MyTestRpc就可以调用,如下:
* 调用:rpc.MyTestRpc.getTestMsg()
* @return
*/
public String getTestMsg()
{
return "噢,成功了!";
}
}2、 JSP的JavaScript中调用的方式,例如:alert(rpc.MyTestRpc.getTestMsg());
推荐音乐【水月洞天】片头曲曲名:绝世 词曲:唐健
演唱:张克帆
世间种种的诱惑 不惊不扰我清梦
山高路远不绝我 追踪你绝美的笑容
登高一呼时才懂 始终在为你心痛
俯首对花影摇动 都是东风在捉弄
世间种种的迷惑 都是因你而猜错
水光月光又交融 描述这朗朗的夜空
生死到头的相从 似狂花落叶般从容
当一切泯灭如梦 就在远山被绝世尘封
啊...
水光月光又交融 描述这朗朗的夜空
生死到头的相从 似狂花落叶般从容
啊...
不扰我清梦 泯灭如梦
都是东风在捉弄 像落叶般从容
Related Links
Following the "JavaScript and Practice of advanced applications," after the introduction of open-source code - json-rpc-for-java light AJAX framework:
Csdn blog authors | Author Sina more than 600 million hits blog | author site
Browser support
IE6, IE7, IE8, FireFox ?(×), Opera (×), Safari (×), Google Chrome (×), etc.
Asynchronous call to support the introduction of asynchronous composite object as a method parameter
Download svn project
http://json-rpc-for-java.googlecode.com/svn/trunk/
Download sample project
Test environment: MyEclipse?, Jre1.4, tomcat 5.0 If you want to test the environment can be used, need not be so high version of the environment 2.8.1example
Download the latest version of the current
JSON-RPC.jar | JsonRpcClient.js
Overview
json-rpc-for-java, is only less than 100 lines of javascript code and less than 10 java files to achieve the adoption of the super-lightweight java objects javaScript quick call and return to the lightweight arbitrary object framework, and support level joint call, which means no additional JavaScript? programming, they can be registered through the javascript to call the java object and return java object, the object is returned if there are ways to return to this in the javascript in the java object variables, You can also continue to call it ..... This is the way to the lightweight json-rpc-for-java's magic. When they returned to the List when the java object, embodied in the javascript for the ArrayList?, If it is Map, reflected in the js in the Object, and other java call in basically the same. Special place is that by JS call java object can only be imported when the parameters of simple types, such as: String, int, float, long, etc..
Notes
If you return to the java client is the Object, Bean, Map or custom objects, can not have attributes name, id, these two attributes for internal use by the framework
json rpc for java use
Please download http://code.google.com/p/json-rpc-for-java/downloads/list
Call not the registration and configuration of the class method
1, first of all, is called the class needs to inherit jcore.jsonrpc.common.JsonRpcObject? Or the realization of interface jcore.jsonrpc.common.face.IjsonRpcObject?, And the default constructor; such as:
package test.rpc; import jcore.jsonrpc.common.JsonRpcObject; public class MyTestRpc extends JsonRpcObject (
/
Call: rpc.getRpcObj ( 'test.rpc.MyTestRpc'). GetTestMsg () @ Return / public String getTestMsg ()
(
return "Oh, a success!";
)
) 2, JSP's JavaScript? Way call, for example: alert (rpc.getRpcObj ( 'test.rpc.MyTestRpc?'). GetTestMsg ()); [Less]