需要设置xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
同时,在请求的时候也不能用json格式请求,应该将json的 “{参数名:参数值}”格式变换为“参数名=参数值”进行请求。
XMLHttpRequest发送Post请求Java Servlet无法解析参数 null
最新推荐文章于 2023-11-29 15:59:01 发布
需要设置xhr.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
同时,在请求的时候也不能用json格式请求,应该将json的 “{参数名:参数值}”格式变换为“参数名=参数值”进行请求。