1.action处理js的request数据
Object postData = ServletActionContext.getRequest().getParameter("postData");
JSONArray jsonArray = JSONArray.fromObject(postData);
此处的postData是ajax请求的一个js数组
2.action发送response数据到js
SchoolCourse sc = new SchoolCourse();
JSONObject jsonObj = JSONObject.fromObjct(sc);
@JSON
public JSONObject getJsonObj() {
return jsonObj;
}
struts.xml
<action..>
<result type="json" >
<param name="includeProperties">
jsonObj
</param>
</result>
</action>