An explanation of the asynchronous invocation mechanism of STRUTS2

Source: Internet
Author: User

First, study case: Modify the page's data without refreshing the current page by changing the name on the getxml.jsp page.

Second, case study:struts and Ajax Coordination, mainly the definition of the return data. We can return data in JSON and XML format. Only the XML method is shown here .

A) format XML data, one is stitching strings, but in the case of many data, code maintenance is not. So here we are using dom4j. Put the downloaded dom4j.jar in the lib directory.

b) Create the scripts package and put the jquery.js in.

c) Create getxml.jsp pages, write html , and jquery.

d) Create Getinfoaction.java. and implement data formatting.

e) Configure the actionin struts.xml . Because we are Ajax requests, we do not need to refresh the page, so we do not configure result.

f) Note:

1. $ ("#bd table:eq (0)"). Remove (); in order to clear the form, or each additional will be more table.

2. The method return value in Action returns NULL. We have already written the data through response before we perform the return , so the return value here is meaningless.

3. the action in Struts.xml does not configure result.

Third, Experience:

A) asynchronous call mechanism is still relatively simple, about JSON Format data We are interested in self-Baidu. In the project, it is common for asynchronous calls to be implemented in a dwr plug-in if there are many places in the project to use . Use jquery If you have fewer words .

b) Although we are background developers, but simple jquery still has to be mastered, we can not say that just learn java , just learn java , in fact, there are a lot of things, we can probably understand, do not require mastery, will be used on the line.

Iv. Reference Items:

Five, a day of joy:

Today I saw a buddy's diary written on:

Dear wife, please, do not put the child's urine into the green tea bottle, the night shift I can't afford to hurt!

The final interpretation of the right to love Partner (www.23hhr.com) All, reproduced please indicate the source.

An explanation of the asynchronous invocation mechanism of STRUTS2

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.