页面JS如下
function postXML(){
if (window.XMLHttpRequest)
req = new XMLHttpRequest();
else if (window.ActiveXObject)
req = new ActiveXObject("Microsoft.XMLHTTP");
else return;
req.open("POST", "http://localhost:8080/mps/orders.do?Action=save");
req.setRequestHeader('content-type', 'text/xml');
req.onreadystatechange = xmlPosted;
req.send(orderDoc);
}
function xmlPosted() {
if (req.readyState != 4) return;
if (req.status == 200) {
var result = req.responseXML;
alert("Records saved successfully");
} else {
}
}
后台action
SAXReader reader = new SAXReader();
Document doc = reader.read(request.getInputStream());