前台部分,是普通的异步提交。
var xmlHttp;
function createXml(){if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
} else {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function save(){
createXml();
xmlHttp.onreadystatechange = callBackFunction;
var temp = {
"name":document.getElementById("name").value
,"pass":document.getElementById("pass").value
,'rand':Math.random()
};
var requestBodyString="requestString="+_jsObjectToJsonString(temp);
var url = "<%=request.getContextPath()%>"+"/login.action?random="+Math.random();
alert(url);
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(requestBodyString);
}
后台action部分。
  System.out.print(this.getRequest().getParameter("requestString"));
Person nsrDjTy = (Person) this.getRequestBody(Person.class,this.getRequestString());
  这里第一次接收到的getParameter("requestString")有值,第二次均为null。因此在下面转换为对象时候报NullPointerException。 急求解。琢磨了好久了,我写了随机数了啊,还是缓存的事吗?也写了请求头了。
  我试时候,刷新N编页面偶尔在提交,后台也能获取值。