Step 1: import the jquery plugin
Copy codeThe Code is as follows: <script type = "text/javascript" src = "js/easyui/jquery-1.8.0.min.js"> </script>
Step 2: add the information display area in <body> </body>.Copy codeThe Code is as follows: <label id = "context"> </label>
Step 3: Add JS Code to the pageCopy codeThe Code is as follows: <script type = "text/javascript">
SetInterval ("Push ()", 1000*60 );
Function Push (){
$. Ajax ({
Type: "POST ",
Url: encodeURI ("crmMaintenance/crmAirpolicyAction-takeAllMonitor.action "),
Success: function (data ){
$ ('# Context'). text (data );
}
});}
</Script>
Step 4: Process requests in Struts2Copy codeThe Code is as follows: public void takeAllMonitor (){
Try {
HttpServletResponse response = ServletActionContext. getResponse ();
PrintWriter out;
Out = response. getWriter ();
Response. setCharacterEncoding ("UTF-8 ");
//... Insert business logic
Out. print ("Synchronous ...");
Out. close ();
} Catch (IOException e ){
E. printStackTrace ();
}
}
By now, you can regularly refresh the page, but there is still a problem, that is, out. when print ("") has Chinese characters, garbled characters may occur. If any hero knows how to handle the problem, he may wish to give some advice.