The method of timing refresh by jQuery, Ajax and struts2


Step 1: import jQuery plug-in

Copy codeThe code is as follows:
<script type=”text/javascript” src=”js/easyui/jquery-1.8.0.min.js”></script>

Step 2: add information display place in < body > < / body >

Copy codeThe code is as follows:

Step 3: add JS code to the page

Copy codeThe code is as follows:
<script type=”text/javascript”>
    function Push() {
           type: “POST”,
           url: encodeURI(“crmMaintenance/crmAirpolicyAction-takeAllMonitor.action”),
           success: function(data) {

Step 4: in struts 2, process the request

Copy codeThe code is as follows:
public void takeAllMonitor() {
        try {
            HttpServletResponse response = ServletActionContext.getResponse();
            PrintWriter out;
            out = response.getWriter();
/ / / insert business logic
                out.print(“Synchronous…” );
        } catch (IOException e) {

At this point, you can achieve the effect of regular refresh page, but there is still a problem, that is out.print When there is Chinese in (“), there is a problem of garbled code. If any great Xia knows how to deal with it, I would like to give some advice.