2020.10.7
问题描述:用post方式往服务器发请求,servlet取不到你传过去的属性的值,显示空。改后的代码如下:
xmlhttp.open("POST","ajaxServlet",true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//3.发送请求
xmlhttp.send("username=tom");
原因:servlet规范:同时满足下列条件,则请求体中的数据将被填充到Parameter集合中,
1:是一个ht