How to handle asynchronous commit (Ajax) in Struts2 1. Original:
HttpServletResponse response = Servletactioncontext.getresponse ();
Response.getwriter (). Write ("Hello" + msg);
Response.getwriter (). Close ();
2. You can use the JSON plug-in provided in STRUTS2
1. Import the JSON plug-in package
Struts2-json-plugin-2.3.15.1.jar under the Struts2 lib package.
2. Configure in the Struts.xml file
1.<package extends= "Json-default" >
2. Set the view <result type= "JSON" >
When this is set, the Valuestack stack top data is converted to JSON.
For our program, the action object is converted to JSON.
<param name= "root" >p</param> if not set, it can be understood to convert the entire action into JSON data. That is
The GetXXX method that is provided in the action is one of the properties in JSON.
If Root is set, only the specified data is converted to JSON.
--------------------------------------------------------
How do I set an object that is converted to JSON to contain no specific attributes?
1. @JSON (Serialize=false) set on the GetXXX method
2. You can also complete the interceptor via the JSON plugin.
<param name= "Includeproperties" >ps\[\d+\]\.name,ps\[\d+\]\.price,ps\[\d+\]\.count</param>
The JSON plugin in 13-STRUTS2 uses