2 回答

TA貢獻(xiàn)1725條經(jīng)驗 獲得超8個贊
如jsp中代碼:
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject();
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
alert(xmlhttp.responseText);//此處獲取返回數(shù)據(jù)
}
}
xmlhttp.open("GET","service/toupdstatus.htm“,true);
xmlhttp.send();
后臺:HttpServletResponse res=ServletActionContext.getResponse();
res.setCharacterEncoding("utf-8");
try {
res.getWriter().write("Has been successfully changed!");
} catch (Exception e) {
e.printStackTrace();
}
到此ok,方法返回類型為void,struts.xml內(nèi)不用寫<result/>標(biāo)簽
- 2 回答
- 0 關(guān)注
- 4208 瀏覽
添加回答
舉報