How to use REST while using Java? [closed]

2019-08-22 05:59发布

I 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.

标签: rest
2条回答
\"骚年 ilove
2楼-- · 2019-08-22 06:29

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);
    }
}     
查看更多
3楼-- · 2019-08-22 06:48

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.

查看更多
登录 后发表回答