I want to set up an application using RESTful principles and Spring. I found out the RESTemplate for the client-side but I don't know how to configure the server. First I want to create a simple application in which the server simply respond with an Hello {name}
string after a myserverapp:8080/{name}
request. Can someone help me, maybe with Java code? Thanks.
Asked
Active
Viewed 788 times
0

observer
- 725
- 4
- 10
- 20
3 Answers
1
You need to start researching a little bit via google.
sample:
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String delete(@PathVariable("id") Integer id)

fmucar
- 14,361
- 2
- 45
- 50
-
I have already read the part about RESTtemplate, and I have already read the part about DispatcherServlet. I have trouble understanding how to bind my Java class and its methods (e.g. 'printUserName()') with the DispatcherServlet and how to call these methods. – observer Feb 27 '12 at 09:57
-
You need to read some spring mvc tutorial as well to understand/learn annotations like @RequestMapping which is used for binding methods to URIs – fmucar Feb 27 '12 at 10:16
1
It really does sound like you need to read the Spring docs and have a look around for examples on the internet (there are a lot)!
Here is one which I think it very clear and straightforward to get you started.

Alex Barnes
- 7,174
- 1
- 30
- 50
0
Might also want to look into using Jersey, allows you to decouple your web layer from your REST layer. Using Spring's method, you need to init a controller etc. can take away from what the purpose of a controller is serving.
I have used both technologies, and it really depends on what you want to do, currently I'm writing an app using backbone.js which uses Jersey to serve up the REST, and Spring MVC as a front end to render the jsp pages.

dardo
- 4,870
- 4
- 35
- 52