angularjs - Request parameter is coming null -
here angular js call
var req = { method: 'post', url: newmessageurl+"/plain", headers: { 'content-type': "text/plain" }, data: {'title':'aaaaa'}//$scope.pubmformmodel }; $http(req).then(function(d){ msgsuccess(); }, function(e){ }); here request
request header accept:application/json, text/plain, */* content-type:text/plain origin:file:// request pauload title: "aaaaa" here spring handler:
@requestmapping(method = requestmethod.post, value = "/newmessage/plain") public responseentity<?> publishmessage(httpservletrequest request) throws exception { here if request.getparameter("title") null
if using jquery, have apply transformer request interpreted spring handler.
for example:
var transformer = function (data) { if (data === undefined) { return data; } return $.param(data); }; and use in requests:
var req = { method: 'post', url: newmessageurl+"/plain?title=aaaa", headers: { 'content-type': "text/plain" }, data: {}, transformrequest: transformer }; $http(req).then(function(d){ //did }, function(e){ //did bad });
Comments
Post a Comment