We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以发现传参方式是request payload,参数格式是json,而并非用的是form传参,所以在后台用接收form数据的方式接收参数就接收不到了 POST表单请求提交时,使用的Content-Type是application/x-www-form-urlencoded, 而此处的Content-Type是:
增添两段代码
解决代码如下;
$http({ method: 'post', url: 'http://localhost:8081/search', data: { "page": page, "pageNum": pageNum }, headers: { //1.设置类型 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }, transformRequest: function(obj) { //2.处理传递参数的格式 var str = []; for (var p in obj) { str.push(encodeURIComponent(p)+"="+encodeURIComponent(obj[p])) } return str.join('&') } }).then(function(data) { }, function(err) { });
现在的谷歌监视为:
现在传参方式就变成form方式了,然后后端就可以正常接收参数了!
The text was updated successfully, but these errors were encountered:
Angular的post请求后台接受不了数据的解决方法
Sorry, something went wrong.
该方法同样适用于AXIOS的POST请求
No branches or pull requests
原因
可以发现传参方式是request payload,参数格式是json,而并非用的是form传参,所以在后台用接收form数据的方式接收参数就接收不到了
POST表单请求提交时,使用的Content-Type是application/x-www-form-urlencoded,
而此处的Content-Type是:
解决
增添两段代码
解决代码如下;
现在的谷歌监视为:
现在传参方式就变成form方式了,然后后端就可以正常接收参数了!
The text was updated successfully, but these errors were encountered: