Url 在 AngularJS 前端和 Spring REST 后端编码
Url Encoding in AngularJS front end with Spring REST backend
快速提问。我有一个 AngularJS 前端与 Spring REST 后端通信。 URL 编码仅对在 url(对于 application/x-www-form-urlencoded)中传递的参数进行编码是必需的。我不必担心正文中的编码,对吗?
对于 application/x-www-form-urlencoded
的内容类型,post 消息的正文需要进行 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);
有关详细信息,请参阅:
快速提问。我有一个 AngularJS 前端与 Spring REST 后端通信。 URL 编码仅对在 url(对于 application/x-www-form-urlencoded)中传递的参数进行编码是必需的。我不必担心正文中的编码,对吗?
对于 application/x-www-form-urlencoded
的内容类型,post 消息的正文需要进行 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);
有关详细信息,请参阅: