I am using spring mvc to set up a rest api and most of the configurations are set up automatically through the spring boot project. On the front end I am using angularjs and
First of all, in Spring 4 you can use @RestController
annotation on your rest controller class, which allows you to remove @RequestBody
annotations from your methods. Makes it cleaner.
For second, would you maybe show more of your angular code? I think you should consider using factory services to make requests to backend. For example, have a service (this service already provides post, get, delete by default):
app.factory('User', function ($resource) {
return $resource("/api/users/:id", {
update: {
method: "PUT"
}
});
});
Now in your Angular controller you make a new User object that you use to call this service methods.
Query all (GET): User.query();
Query one (GET): User.get({id: userId});
Insert (POST): User.$save();
Update (PUT): User.$update();
Remove (DELETE): User.delete({id: userId}
I've written my Angular apps like that also using Spring boot and works well.