angularJs $http. cannot revice params from request -
angularjs code:
$http({ method: 'post', url:'/hello/rest/user/test', data: {user: 'aaaaa'} });
server code:
@post @path("/test") public response merge(@context httpservletrequest request) { system.out.println(request.getparameter("user")); if (request.getparameter("user") == null) { return response.status(status.bad_request).build(); } return response.ok().build(); }
request.getparameter("user") null. cannot revice parameter way.
if want use request parameter, need pass data
$http.post('/hello/rest/user/test', { user : 'aaaaa' }, { headers : { "content-type" : 'application/x-www-form-urlencoded;charset=utf-8' }, transformrequest : [function(data) { return angular.isobject(data) ? jquery.param(data) : data; }] });
also read this question