2 Rest Services - shijazi88/springboot GitHub Wiki
Example 1 (Create Get, Post, Put, Delete Request using @Controller and @ResponseBody) Steps:
- Create project using STS or Spring Initializr
- Add Web Dependency in pom.xml
- Create Domain Class (i.e. User)
- Create UserController class
- Add @Controller annotation to UserController class
- Add @RequestMapping annotation to UserController class @RequestMapping(value="api")
- Define static List users variable to simulate database and add 2 users to the list
- Create new method to return all users in static list (getAllUsers)
- Add @RequestMapping(value="users", method=RequestMethod.GET)
- Run the application and call this URL http://localhost:8080/api/users