2 回答

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
如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);//此處獲取返回?cái)?shù)據(jù)
}
}
xmlhttp.open("GET","service/toupdstatus.htm“,true);
xmlhttp.send();
后臺(tái):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)簽
添加回答
舉報(bào)