且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Content-Type头没有被设定角$ HTTP

更新时间:2021-08-12 07:43:31

我不知道,如果你不发送任何数据内容类型头将被发送。添加数据对象和尝试:

I'm not sure the Content-Type header will be sent if you are NOT sending any data. Add a data object and try it:

return $http({
    method: 'POST',
    //withCredentials:true,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    data: data,
    url: url
});

此外,通常使用数据后而不是 PARAMS (获取)。

您也可以参考此SO疑问,对如何,如果你需要转换数据一些更多的信息:How我可以让angular.js后的数据作为表格数据,而不是请求负载?

You can also refer to this SO question that has some more info on how to transform the data if you need to: How can I make angular.js post data as form data instead of a request payload?