The memory is too bad. Take a note ,,,
Step 1:
Download the dwr jar package and place it in the lib folder;
Click Open Link
Step 2:
Configure DWR in web. xml;
[Html]
<Servlet>
<Servlet-name> dwr-invoker </servlet-name>
<Servlet-class> uk. ltd. getahead. dwr. DWRServlet </servlet-class>
<Init-param>
<Param-name> debug </param-name>
<Param-value> true </param-value>
</Init-param>
</Servlet>
<Servlet-mapping>
<Servlet-name> dwr-invoker </servlet-name>
<Url-pattern>/dwr/* </url-pattern>
</Servlet-mapping>
<Servlet>
<Servlet-name> dwr-invoker </servlet-name>
<Servlet-class> uk. ltd. getahead. dwr. DWRServlet </servlet-class>
<Init-param>
<Param-name> debug </param-name>
<Param-value> true </param-value>
</Init-param>
</Servlet>
<Servlet-mapping>
<Servlet-name> dwr-invoker </servlet-name>
<Url-pattern>/dwr/* </url-pattern>
</Servlet-mapping> Step 3:
Create the DWR configuration file dwr. xml
[Html]
<Dwr>
<Allow>
<Create creator = "new" javascript = "AjaxBean">
<Param name = "class" value = "com. test. ajax. AjaxBean"/>
</Create> -->
<Create creator = "new" javascript = "AjaxMonitor">
<Param name = "class" value = "com. anthony. struts2.action. MonitorAction"/>
</Create>
<! -- Configure the DWR form validators -->
<Create javascript = "validator" creator = "new">
<Param name = "class"
Value = "org. apache. struts2.validators. DWRValidator"/>
</Create>
<Convert converter = "bean"
Match = "com. opensymphony. xwork2.ValidationAwareSupport"/>
</Allow>
<Signatures>
<! [CDATA [
Import java. util. Map;
Import org. apache. struts2.validators. DWRValidator;
DWRValidator. doPost (String, String, Map <String, String> );
]>
</Signatures>
</Dwr>
<Dwr>
<Allow>
<Create creator = "new" javascript = "AjaxBean">
<Param name = "class" value = "com. test. ajax. AjaxBean"/>
</Create> -->
<Create creator = "new" javascript = "AjaxMonitor">
<Param name = "class" value = "com. anthony. struts2.action. MonitorAction"/>
</Create>
<! -- Configure the DWR form validators -->
<Create javascript = "validator" creator = "new">
<Param name = "class"
Value = "org. apache. struts2.validators. DWRValidator"/>
</Create>
<Convert converter = "bean"
Match = "com. opensymphony. xwork2.ValidationAwareSupport"/>
</Allow>
<Signatures>
<! [CDATA [
Import java. util. Map;
Import org. apache. struts2.validators. DWRValidator;
DWRValidator. doPost (String, String, Map <String, String> );
]>
</Signatures>
</Dwr> Step 4:
Access http: // localhost: 8080/PoliceMap02/dwr, that is, add dwr to the end of your project to obtain the following resources:
[Html]
<Script src = "./dwr/engine. js"> </script>
<Script src = "./dwr/util. js"> </script>
<Script src = "./dwr/interface/AjaxMonitor"> </script>
<Script src = "./dwr/engine. js"> </script>
<Script src = "./dwr/util. js"> </script>
<Script src = "./dwr/interface/AjaxMonitor"> </script> place the preceding Resources in the header of the page.
Step 5:
Test:
Page Submission request
[Javascript]
// Set the SMS center number
Function SetPhoneSMS (){
Var key = onlineList. options [onlineList. selectedIndex]. value;
Var num = document. getElementById ('setphonenum'). value;
Window. alert (num );
AjaxMonitor. setPhoneNum (key, num, processSMS );
}
// Set the SMS center number
Function SetPhoneSMS (){
Var key = onlineList. options [onlineList. selectedIndex]. value;
Var num = document. getElementById ('setphonenum'). value;
Window. alert (num );
AjaxMonitor. setPhoneNum (key, num, processSMS );
}
Background processing:
[Java]
<SPAN style = "WHITE-SPACE: pre"> public class MonitorAction {</SPAN>
Public class MonitorAction {[java] view plaincopyprint? Public String setPhoneNum (String key, String num ){
Int type = OrderSet. SMSCENTERNUM;
SendSetSMSCenterNumber centerNumber = new SendSetSMSCenterNumber ();
CenterNumber. setSMSNum (num );
Byte [] bytes = centerNumber. toBytes ();
HandleSend. parseOrder (type, key, bytes );
Return null;
}
Public String setPhoneNum (String key, String num ){
Int type = OrderSet. SMSCENTERNUM;
SendSetSMSCenterNumber centerNumber = new SendSetSMSCenterNumber ();
CenterNumber. setSMSNum (num );
Byte [] bytes = centerNumber. toBytes ();
HandleSend. parseOrder (type, key, bytes );
Return null;
}