DWR: Easy AJAX for JAVA
DWR is a RPC library which makes it easy to call Java functions from JavaScript and to call JavaScript functions from Java (a.k.a Reverse Ajax).
DWR是一个远程程序调用库,可以很容易地从javascript中调用java方法和从java中调用js方法。
It has a large user-base,active mailing list and has been used in many projects.
dwr有很广泛的用户基础,活跃的邮件列表而且已经用于许多项目中去了。
DWR has a number of features like call batching,marshalling of virtually any data-structure between Java and Javascript (including binary file uploading and downloading),exception handling,advanced CSRF protection and deep integration with several Java server-side technologies like Spring and Guice.
dwr有很多特点如:批量调用,编组任何介于Java和Javascript(包括二进制文件的上传和下载)的数据框架,异常处理,先进的CSRF保护 和 将java服务端的一些技术如Spring、Guice的深度整合。
The first diagram shows how DWR can alter the contents of a selection list as a result of some Javascript event.
第一个图显示了DWR是如何通过一些js事件来修改一个选择列表的内容的
Reverse Ajax (available since DWR version 2.0) allows Java code running on the server to find out what clients are viewing certain pages,and to send to them JavaScript,generated either manually or using a Java API. These JavaScript generating APIs generally match a client-side APIs.
相反,ajax允许java代码在服务器上运行来找出哪些客户在浏览的某些网友,并发给这些客户手动活用javaAPI生成的js。这些js生成的API一般匹配客户端的API
DWR consists of two main parts:
DWR包括两个主要的部分:
- A Java Servlet running on the server that processes requests and sends responses back to the browser.
- 一个服务器上运行的Servlet类,能处理请求和发送响应返回给浏览器运行。
- JavaScript running in the browser that sends requests and can dynamically update the webpage.
- 运行在浏览器的js发送能请求且能动态地刷新web页面。
DWR works by dynamically generating Javascript based on Java classes. The code does some Ajax magic to make it feel like the execution is happening on the browser,but in reality the server is executing the code and DWR is marshalling the data back and forwards.
DWR通过动态生成基于java类的javascript来运行。代码起到了ajax的功能感觉像是在浏览器执行的
This method of remoting functions from Java to JavaScript gives DWR users a feel much like conventional RPC mechanisms like RMI or SOAP,with the benefit that it runs over the web without requiring web-browser plug-ins.
For details on how to get started with DWR see the getting started guide and download instructions.
原文链接:https://www.f2er.com/ajax/166595.html