尝试用Ext.Ajax异步操作来改变页面回显的值,试了好几次都没成功,终于啊,试出来试出来了,功夫不负有心人。(开心)
具体如下:
js代码:
<script type="text/javascript"> Ext.onReady(function(){ var djzcqh = Ext.getCmp('djzcqh').getValue(); Ext.Ajax.request({ url: '<%=ctxPath%>/lr/areaAction.do?method=getDjzcqhName', //url携带参数 params:{ djzcqh:djzcqh }, success: function(response){ //获取后台response写入的值 var data =response.responseText; Ext.getCmp('assistant3').setValue(data); } }); }); </script>
后台代码(struts1):
public ActionForward getDjzcqhName(final ActionMapping mapping, final ActionForm actionForm, final HttpServletRequest request, final HttpServletResponse response) throws IOException { String djzcqh = request.getParameter("djzcqh"); response.setCharacterEncoding("UTF-8"); String djzcqhName =bs.getDjzcqh(djzcqh); //将要回显的值写出去 response.getWriter().write(djzcqhName); return null; } 总体描述一下,当Jsp页面加载完执行JS通过ajax异步请求url,后台方法执行完成后,将值通过response写出去,请求完成后,执行成功函数,通过response.responseText就可以获得后台写出去的值,然后就可以随便操作该数据了。