【Introduction to DWR】

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 (Direct Web Remoting) is a remote server-side Ajax open source framework for improving the interaction between web pages and Java classes, which can help developers develop websites that include AJAX technology. It allows code in the browser to use JAVA functions running on the web server as if it were in the browser.



 

DWR (Direct Web Remoting) is a WEB remote invocation framework. Using this framework can make AJAX development very simple. Using DWR, you can use JavaScript on the client to directly call the Java method of the server and return the value to JavaScript, just like a direct local client Calls are the same (DWR dynamically generates JavaScript code based on Java classes). Its latest version, DWR0.6, adds many features such as: support for automatic configuration of Dom Trees, support for Spring (JavaScript remote call spring beans), better browser support, and Support for an optional commons-logging journaling operation.

 

advantage:

1. Browser compatible:

2. Encapsulation of json

3. Conversion of various objects (ssh object conversion)

4. You can write less JS code and do more things

 

shortcoming:

1. Errors are not easy to find

2. The dwr configuration is very complicated

 



 

working principle 

DWR works by dynamically generating Java classes into Javascript. Its code is like Ajax magic, you feel that the call is happening on the browser side, but in fact the code call happens on the server side, and DWR is responsible for the transfer and transformation of the data. This way of calling functions remotely from Java to JavaScript makes DWR use a regular RPC mechanism very much like RMI or SOAP, and DWR has the advantage of running on web pages without any web browser plug-ins. Java is fundamentally synchronous, whereas AJAX is asynchronous. So when you call a remote method, when the data has been returned from the network, you need to provide a DWR with a callback function.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326325396&siteId=291194637