2016-12-04 88 views

回答

1

对于内容类型的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); 

有关详细信息,请参见:

+0

我想这是只有在参数传递有如果POST方法与内容型'应用/ json'的AngularJS框架将自动对其进行编码为JSON使用此 –

+0

关心自己的URL。如果内容类型是“application/x-www-form-urlencoded”,则主体需要被uri编码。 – georgeawg