在JS中发送数据
function calculate(){
var myFormat = document.calculateForm.myFormat.value;
var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP.6.0");
var url = "servlet/DealServlet?myFormat="+myFormat;
alert(url);
xmlHttp.open("POST", url, true);
xmlHttp.onreadystatechange = function(){
if(xmlHttp.readyState == 4){
resultDiv.innerHTML = xmlHttp.responseText;
}
else{
resultDiv.innerHTML = "正在计算请稍后";
}
};
xmlHttp.setRequestHeader("Content-Type","text/plain;charset=UTF-8");
xmlHttp.send();
}
然后在servlet中获取
String myFormat = URLEncoder.encode(request.getParameter("myFormat"));
但是我想传一个想这样的:(4+5)-(3+4)
但是收到的是乱码:%284+5%29-%283+4%29不能识别括号。怎么办?
求大神解决
PS:网上百度了很多种编码方式,并没有找到对+和()都不编码的