ajax提交数据到Struts2中的Action
大家好,打扰下大家哈。。
小弟有个地方不明白了.就是我用AJAX来提交页面上输入框的值,不用表单(form)。但是Action中的user始终获得不到值。
在Action 中式这样这写的
public class userinfoActon extends ActionSupport{
Userinfo user;
//提供get和set方法
......
Public String execute(){
consumebiz.getResult(user);
return SUccess;
}
jsp页面是这样写的
<input type="test" name="user.username"/>
<input type="passsword" name="user.password"/>
}
在ajax这样写的
if (window.ActiveXObject) {
xmlReq = new ActiveXObject("Microsoft.XMLHTTP");
} else {
xmlReq = new XMLHttpRequest();
}
if (xmlReq) {
xmlReq.open("post", "getres.action, true);
xmlReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlReq.onreadystatechange = callback;
xmlReq.send(null);
}
不知道该怎么解决,请大家帮忙哈..谢谢了