getrequest ajax怎么獲得后臺response.getWriter.print返回的數(shù)據(jù)?
ajax怎么獲得后臺response.getWriter.print返回的數(shù)據(jù)?您需要使用ajax來實現(xiàn)這一點。換句話說,在JS中,1創(chuàng)建一個新的XMLHttpRequest對象(例如:xmlhttp
ajax怎么獲得后臺response.getWriter.print返回的數(shù)據(jù)?
您需要使用ajax來實現(xiàn)這一點。換句話說,在JS中,1創(chuàng)建一個新的XMLHttpRequest對象(例如:xmlhttp)2。向XMLHttpRequest對象發(fā)送請求:xmlhttp.open(“get”,“URL”,true)請注意,其中的URL是Struts2跳轉到的操作測試操作3. 采用struts.xml文件找到URL跳轉到的操作并將其寫入execute方法響應.getWriter(). Write(“aaaaa”)Struts2 get httpresponse對象,對嗎ServletActionContext.getResponse服務()(不要忘記在execute方法的末尾添加一個returnnull語句作為execute方法的返回。)4. 在JS:VAR resultstr=xmlhttp.responseText文件異步傳輸完成后,resultstr將被分配到“AAAAA”。上面提到的步驟1、2和4都涉及Ajax內容。如果你不懂Ajax,你需要先學習Ajax的基本用法