angularjs - Post query parameter from angular js to java rest server -
i trying post query parameters angular js rest server. value received in rest null. can please tell missing?
angular code,
$http({ method : 'post', url : '/rest/user/changepassword', info : {'id':$scope.user.id, 'password':$scope.user.password, 'newpassword':$scope.user.newpassword}, headers: {'content-type': 'application/x-www-form-urlencoded'} }).success(function(data){ console.log(' info '); }); rest code,
@path("/changepassword") @post @produces(mediatype.application_json) @consumes(mediatype.application_form_urlencoded) public response changepassword(@queryparam("id") int id, @queryparam("password") string password, @queryparam("newpassword") string newpassword, @context uriinfo request) { system.out.println(" id " + id + " re " + request.getqueryparameters().getfirst("id")); system.out.println(" password " + password + " "+ request.getqueryparameters().getfirst("password")); system.out.println(" newpassword " + newpassword + " " + request.getqueryparameters().getfirst("newpassword") ); homecoming new response('asd'); } i tried $.param in angular side, tried parameters httpservletrequest result null.
@queryparam used pick values passed across in query string in requests.
create java object has variables matching info structure, , utilize input instead of separate variables.
angularjs rest spring-mvc
No comments:
Post a Comment