java - Problems with storing data into database using angularjs and spring boot -


this have:

user.java

@entity public class user {      @id     @generatedvalue(strategy=generationtype.identity)     private integer id;      @column     private string username;      @column     private string password;      @column     private string lastname;      public integer getid() {         return id;     }      public string getlastname() {         return lastname;     }      public string getpassword() {         return password;     }      public string getusername() {         return username;     } } 

usercontroller.java

@restcontroller @requestmapping("/user") public class usercontroller {     @autowired     private userrepository repo;      @requestmapping(method = requestmethod.post)     public user adduser(@requestbody user user) {         return repo.saveandflush(user);     } 

user.service.js

note: here console output 3 values of username,password , lastname.

    function create(user) {          console.log(user.username)         console.log(user.password)         console.log(user.lastname)           return $http.post('/user', user).then(handlesuccess, handleerror('error creating user'));     } 

registration.controller

(function () {     'use strict';      angular         .module('app')         .controller('registercontroller', registercontroller);      registercontroller.$inject = ['userservice', '$location', '$rootscope', 'flashservice'];     function registercontroller(userservice, $location, $rootscope, flashservice) {         var vm = this;          vm.register = register;          function register() {             vm.dataloading = true;             userservice.create(vm.user)                 .then(function (response) {                     if (response.success) {                         flashservice.success('registration successful', true);                         $location.path('/login');                      } else {                         flashservice.error(response.message);                         vm.dataloading = false;                     }                 });         }     }  })(); 

registration.html

<div class="container" ng-controller="registercontroller vm"> <div class="col-md-6 col-md-offset-3">     <h2>register</h2>     <div ng-show="vm.error" class="alert alert-danger">{{vm.error}}</div>     <form name="form" ng-submit="vm.register()" role="form">           <div class="form-group" ng-class="{ 'has-error': form.lastname.$dirty && form.lastname.$error.required }">             <label for="lastname">last name</label>             <input type="text" name="lastname" id="lastname" class="form-control" ng-model="vm.user.lastname" required />             <span ng-show="form.lastname.$dirty && form.lastname.$error.required" class="help-block">last name required</span>         </div>          <div class="form-group" ng-class="{ 'has-error': form.username.$dirty && form.username.$error.required }">             <label for="username">username</label>             <input type="text" name="username" id="username" class="form-control" ng-model="vm.user.username" required />             <span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">username required</span>         </div>           <div class="form-group" ng-class="{ 'has-error': form.password.$dirty && form.password.$error.required }">             <label for="password">password</label>             <input type="password" name="password" id="password" class="form-control" ng-model="vm.user.password" required />             <span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">password required</span>         </div>         <div class="form-actions">             <button type="submit" ng-disabled="form.$invalid || vm.dataloading" class="btn btn-primary">register</button>             <img ng-if="vm.dataloading" src="data:image/gif;base64,r0lgodlheaaqapiaap///waaamlcwkjcqgaaagjiyokcgpkskih/c05fvfndqvbfmi4waweaaaah/hpdcmvhdgvkihdpdgggywphegxvywquaw5mbwah+qqjcgaaacwaaaaaeaaqaaadmwi63p4wyklre2mioggznadomgyjrbexwroumcg2lmdewnhqlvsyod2mbzkydadka+diaaah+qqjcgaaacwaaaaaeaaqaaadnai63p5ojcegg4qmu7dmikrxqlfuydezigbmrvsaqhwctxxf7weyb4ag1xjihkmzsiukkhiaifkecqoaaaasaaaaabaaeaaaazyiujijk8pbyjdmlfyvbovjha70gu7xsujhmktwhpakzlo9hmaokwjz7rf8aypddzkpzbqfvwqaifkecqoaaaasaaaaabaaeaaaazmiumilk8oyhphsnfzfhyumcyuhdaqxridhhbgqrokw0r8dyljd8z0fmdgsgo/iphi5taaaifkecqoaaaasaaaaabaaeaaaaziiunink0rnzbtwgpnmgqwmdsngxgjuliweur5owuipz8paeame6twfwyysgo/ipfksaaah+qqjcgaaacwaaaaaeaaqaaadmwi6imkqorfjdoe82p4wgccc4ceuqradylesojembgsuc2g7sdx3lqgbmlajibufbslkaaah+qqjcgaaacwaaaaaeaaqaaadmgi63p7wcrhznfvdmghu2nfwlwci3wgc3tswhufgxtaukgcbtgenbmjaejsxgmlwzpeaach5bakkaaaalaaaaaaqabaaaamyclrc/jdksatlqtsckdcecajdii7hcq4emtcpyrcuubjcyrghvtqlaib1yhicnlsrkaaaowaaaaaaaaaaaa==" />             <a href="#/login" class="btn btn-link">cancel</a>         </div>     </form> </div> </div> 

but reason outcome of user.

{id: 1, username: "33", password: "33", lastname: null} id: 1 lastname: null password: "33" username: "33" 

no matter keeps saying null. , don't know i'm missing

does has clue on this. think keep overlooking something.

your view , service specify data lastname lastname, model in lowercase.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -