0
quick question。我有一个AngularJS前端与Spring REST后端进行通信。只有在URL中传递参数时,URL编码才是必需的(对于application/x-www-form-urlencoded)。我不必担心身体的编码,对吗?Url在AngularJS前端使用Spring REST后端进行编码
quick question。我有一个AngularJS前端与Spring REST后端进行通信。只有在URL中传递参数时,URL编码才是必需的(对于application/x-www-form-urlencoded)。我不必担心身体的编码,对吗?Url在AngularJS前端使用Spring REST后端进行编码
对于内容类型的application/x-www-form-urlencoded
需要被URI编码后消息的主体:
$http({
url: myUrl,
method: 'POST',
data: $httpParamSerializerJQLike(myData),
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
OR交替:
var config = {
transformRequest: $httpParamSerializer,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
$http.post(myUrl, myData, config);
有关详细信息,请参见:
我想这是只有在参数传递有如果POST方法与内容型'应用/ json'的AngularJS框架将自动对其进行编码为JSON使用此 –
关心自己的URL。如果内容类型是“application/x-www-form-urlencoded”,则主体需要被uri编码。 – georgeawg