How to use REST while using Java? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and cit开发者_如何学Cations.
Closed 7 years ago.
Improve this questionI am using Spring MVC and want to develop a website that uses REST API provided by LinkedIn. I am very new to REST and have no Idea of how to use REST and retrieve data. I want a full tutorial so as to start up with my REST application. Please help me out through this.
For consuming RESTful services the core class provided by spring is RestTemplate
The spring blog has a pretty good article on how to use the RestTemplate.
A very simplified example is:
class MyServiceClient {
RestTemplate rest = new RestTemplate();
public String get(String thingy){
return rest.get("http://www.example.com/api/stuff/{thingy}", String.class, thingy);
}
}
Try out rest4j. It integrates with Spring, but unlike Spring MVC, rest4j can generate documentation and client libraries for different programming languages.
There is also a flexible mechanism for mapping your internal Java object to external JSON representation, which is very important when using an ORM.
精彩评论