servelet 学习

Action如何通过Servlet和js交互
以某项目为例:
1. public class initScheduleAction extends WbxAction{

public ActionFoward process(ActionMapping mapping ActionForm form,
HttpServlet request reques, HttpServletResponse response) throws WbxException:

***;

request.setAttribute("respData", meetingItemData);

return mapping.findForward(forward);

}

}

2. 在schedule.jsp中拿到respData
respJson = <%=  request.getAttribute("respData") %>;

3. 在schedule.js中 直接取出respJson对象,对其属性处理,来实现业务逻辑。

4. 在schedule.js中 create postData对象,把页面元素存在 postData中,并对其扩张,生成var orionData = $.extend(self.postData, {
actionType : 'updateSave''
...;
});
5. Ajax call schedulerAction.java, 完成页面跳转,生成新的meeting.
orion.ajax.request(
"/orion/meeting/scheduler?rnd=" + Math.random(),
"post",
orionData,
self,
self.schedulerSuccess,
self.schedulerFailure);

你可能感兴趣的:(JavaScript,jsonp,Ajax,servlet)