Dwr3.0 Pure Annotation (pure Java code Configuration) configuration and application analysis of two front-end call back-end _java

Source: Internet
Author: User
Tags call back server port

First, when we configure the DWR3, we can test in the browser to see if our configured DWR is effective

http://localhost:[Your server port number, default does not write as 80]/[Web name]/dwr/, enter the name of the DWR script you defined earlier, as shown below:

When you click the first remote you will see the following page:

Such a page shows that your DWR basic configuration succeeded, why said the basic success, because it shows you this service component all the way, but one thing is, only you annotate the @remotemethod method you have the right to access directly on the page, Otherwise it will be an error;

Then we can really use the page to access the background method, before you have to in your *.js file contained in the *.html file to introduce the following three files, as follows:

<script type= ' text/javascript ' src= ' Web path/dwr/engine.js ' >
</script><script type= ' text/ JavaScript ' src= ' Web path/dwr/util.js ' >
</script>

This is the DWR default must be cited, the principle does not explain, the following to refer to the one you want to call this service component (Java Class), the equivalent of JS file, that is, dwr the back end of the service class equivalent to directly into the front-end JS file, Inside the method is equivalent to this JS file inside the method, as long as the reference in can be directly called, as follows:

<script type= ' text/javascript ' src= ' Web path/dwr/interface/remote.js ' >
</script>

Then down can be in our JS directly call this remote class inside the method, as follows:

(function ($) {remote.setenabledwrupdate ();} ;

Remote Inside the Setenabledwrupdate () is the previous one of the Sessionexpiredparam class Setenabledwrupdate () method;

The front end of the call to the end of the OK, the next is how the back end of the call to the front end, in advance to everyone play through the ^_^;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.