快速提问。我有一个与Spring REST后端通信的AngularJS前端。 URL编码仅用于编码在url中传递的参数(对于application / x-www-form-urlencoded)。我不必担心身体的编码,对吗?
答案 0 :(得分:1)
对于application/x-www-form-urlencoded
的内容类型,帖子消息的正文需要进行uri编码:
$http({
url: myUrl,
method: 'POST',
data: $httpParamSerializerJQLike(myData),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
或者替代:
var config = {
transformRequest: $httpParamSerializer,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
$http.post(myUrl, myData, config);
有关详细信息,请参阅: