content-type = ‘application/x-www-form-urlencoded’ (不支持@RequestBody annotation)
前端传值template string为如下形式1
2
3
4
5
6
7
8
9
10
11
12
13
14var http = new XMLHttpRequest();
var url = 'get_data.php';
var params = 'orem=ipsum&name=binny';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
alert(http.responseText);
}
}
http.send(params);
var params = ‘orem=ipsum&name=binny’;
content-type = ‘application/json’ (支持@RequestBody annotation)
1 | let request = new XMLHttpRequest() |