I want the client and server application to talk to each other using REST services. I have been trying to design this using Spring MVC. I am looking for something like this:
- Client does a POST rest service call
saveEmployee(employeeDTO, companyDTO)
- Server has a similar POST method in its controller
saveEmployee(employeeDTO, companyDTO)
Can this be done using Spring MVC?
Yes, Rest is very easy to implement using spring MVC.
Yes, this can be done. Here's a simple example (with Spring annotations) of a RESTful Controller:
Note that there are multiple ways of handling the incoming data from http-request (@RequestParam, @RequestBody, automatic mapping of post-parameters to a bean etc.). For longer and probably better explanations and tutorials, try googling for something like 'rest spring mvc' (without quotes).
Usually the clientside (browser) -stuff is done with JavaScript and AJAX, I'm a server-backend programmer and don't know lots about JavaScript, but there are lots of libraries available to help with it, for example see jQuery
See also: REST in Spring 3 MVC