var Ajax = {
xmlHttp:"",
getYear:function(){
return document.getElementById("SY").selectedIndex+1900+"";
},
getMonth: function (){
return document.getElementById("SM").selectedIndex+1+"";
},
createXMLHttpRequest:function () {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
},
send:function () {
this.createXMLHttpRequest();
xmlHttp.onreadystatechange = this.showResponse;
xmlHttp.open("POST", "DateSetAjax.action?toShowYearMonth="+ leftPad(this.getYear ())+"-"+leftPad(this.getMonth()), false);
xmlHttp.send("yearmonth=aa");
},
showResponse:function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
var data = xmlHttp.responseText;
if(data=="null")
data = "";
CLD.date1.value=data;
}
}
}
}
xmlHttp:"",
getYear:function(){
return document.getElementById("SY").selectedIndex+1900+"";
},
getMonth: function (){
return document.getElementById("SM").selectedIndex+1+"";
},
createXMLHttpRequest:function () {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
},
send:function () {
this.createXMLHttpRequest();
xmlHttp.onreadystatechange = this.showResponse;
xmlHttp.open("POST", "DateSetAjax.action?toShowYearMonth="+ leftPad(this.getYear ())+"-"+leftPad(this.getMonth()), false);
xmlHttp.send("yearmonth=aa");
},
showResponse:function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
var data = xmlHttp.responseText;
if(data=="null")
data = "";
CLD.date1.value=data;
}
}
}
}
Ajax.send(); 发送请求。
上面代码 参数必须在附在url 后面 才能在struts2中取到。xmlHttp.send("yearmonth=aa"); 中的参数并不起作用。
send 怎么发送数据呢
ServletActionContext.getRequest().getParameter(key); ok
ActionContext.getContext().get("request").get(key); null.