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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -