Building a RESTful Web Service

来源:互联网 发布:网络购物平台有哪些 编辑:程序博客网 时间:2024/05/18 16:57

建一个RESTFul web service 服务.

1 IDE:  IntelliJ IDEA;

2 项目为Maven项目.

---------目标----------------

What you’ll build

You’ll build a service that will accept HTTP GET requests at:

http://localhost:8080/greeting

and respond with a JSON representation of a greeting:

{"id":1,"content":"Hello, World!"}

You can customize the greeting with an optional name parameter in the query string:

http://localhost:8080/greeting?name=User

The name parameter value overrides the default value of "World" and is reflected in the response:

{"id":1,"content":"Hello, User!"}
-------------------过程----------------------

Download and unzip the source repository for this guide, or clone it using Gitgit clone https://github.com/spring-guides/gs-rest-service.git


With IntelliJ IDEA up and running, click Import Project on the Welcome Screen, or File | Open on the main menu:

选择 pom.xml

运行即可!

-------------------验证----------------- 

浏览器中输入 上文提到的地址即可!

原创粉丝点击