前段时间,遇到一个问题,现在想想自己那时钻了牛角尖,一直卡在哪里。今天想起来,把其记下来,惊醒自己。
实现的功能:显示详细数据
1、ajax---使用的是jquery的ajax【action不跳转】
ajax() 方法通过 HTTP 请求加载远程数据。
ajax是在前端提交数据,然后后台获取传递过来的参数,经过处理,ajax获取返回的json数据。【ajax捕获到json数据之后,再进行处理】。只要是url是正确的。
<span style="white-space:pre"> </span>ServletActionContext.getResponse().setContentType("text/json;charset=utf-8");
<span style="white-space:pre"> </span>ServletActionContext.getResponse().getWriter().print(applyForm);
区别:
<action name="getUserImpowerReqInfo" class="org.UserImpowerDealAction" method="getUserImpowerReqInfo"></action>
2、在action中直接跳转【action跳转】
不返回数据,直接跳转页面,整个处理都在action请求中处理。
ServletActionContext.getResponse().setContentType("text/json;charset=utf-8");
ServletActionContext.getResponse().getWriter().print(applyForm);
区别:
<span style="white-space:pre"> </span><action name="getUserImpowerReqInfo" class="org.UserImpowerDealAction" method="getUserImpowerReqInfo">
<result name="officer">/admin/bpm/userImpower/officer.jsp</result>
</action>