java - Spring MVC + AngularJS - 415 (Unsupported Media Type) -


i had working until added department attribute in employee model onetomany , manytoone relation database. java controller method:

@requestmapping(value = "/addemployee" , method = requestmethod.post) public responseentity<void>addemployee(@requestbody employee empl, uricomponentsbuilder ubuilder){     system.out.println(empl);     employeedao.addentity(empl);     httpheaders headers = new httpheaders();     headers.setlocation(ubuilder.path("/addemployee/{id}").buildandexpand(empl.getemp_id()).touri());     return new responseentity<void>(headers,httpstatus.created); } 

i tried adding

consumes = {"application/json;charset=utf-8"}) 

as seen in other similar questions didn't work.

here angular service method:

addemployee: function(employee){         return $http.post('http://localhost:8080/project/addemployee',employee).then(                 function(resp){                     console.log('added empl')                     return resp.data;                 },                 function(error){                     alert('error adding employee');                     return $q.reject(error);                 }         );     }, 

and angular controller method adding:

this.addemployee = function(employee){     employeesservice.addemployee(employee).then(             this.getallemployees,             function(error){                 console.log('error adding employee'+employee);}     );  }; 

i don't have exceptions on server-side, only

post http://localhost:8080/project/addemployee 415 (unsupported media type) 

in browser's console


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -