Spring/AngularJS- receiving null data on server -


on ui/form have

        <div ng-controller="myformcontroller">           <form  name="dataform" ng-submit="submitform()">             first name:<br>             <input type="text" ng-model="user.firstname" value="{{user.firstname}}"><br>             last name:<br>             <input type="text" ng-model="user.lastname" value="{{user.lastname}}">             <br><br>             <input type="submit" value="submit">           </form>           </div> 

and controller on ui-side configured

            mycontrollers.controller('myformcontroller', ['$scope','$http', function myformcontroller( $scope, $http){                 $scope.user = {                     "firstname": "firsname",                     "lastname": "lastname",                     "gender" : "default"                 };                   $scope.submitform = function(){                     alert('1');                      var formdata = $scope.user;                      $http.post('getuserdetails', {formdata}).                       success(function(serverdata, status, headers, config) {                         $scope.user = serverdata;                       }).                       error(function(data, status, headers, config) {                          alert('failed');                       });                        };             }]); 

on server side have pojo

            public class user {                 private string firstname;                 private string lastname;                 private string gender;                  public string getfirstname() {                     return firstname;                 }                  public void setfirstname(string firstname) {                     this.firstname = firstname;                 }                  public string getlastname() {                     return lastname;                 }                  public void setlastname(string lastname) {                     this.lastname = lastname;                 }                  public string getgender() {                     return gender;                 }                  public void setgender(string gender) {                     this.gender = gender;                 }              } 

with controller

            @requestmapping(value="/getuserdetails", method = requestmethod.post)                public string senddetails(@requestbody user user ) {                 system.out.println("in here");                 system.out.println(user.getfirstname());                 user tosend = new user();                 tosend.setfirstname(user.getfirstname()+" first ");                 tosend.setlastname(user.getlastname()+ " last ");                 tosend.setgender("male");                  string json ="";                 objectwriter ow = new objectmapper().writer().withdefaultprettyprinter();                  try {                     json = ow.writevalueasstring(tosend);                 } catch (jsonprocessingexception e) {                     e.printstacktrace();                 }                  return json;               } 

now when submit see "in here" on server console. second

system.out.println(user.getfirstname()); 

is showing null.

what missing?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -