标签:ota bind variable pos create tco ram spring end
In Spring boot, define a REST API endpoint is pretty easy.
package com.globomatisc.bike.controllers; import java.util.ArrayList; import java.util.List; import com.globomatisc.bike.models.Bike; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/v1/bikes") public class BikesController { @GetMapping public List<Bike> list() { List<Bike> bikes = new ArrayList<>(); return bikes; } @PostMapping @ResponseStatus(HttpStatus.OK) public void create(@RequestBody Bike bike) { } @GetMapping("/{id}") public Bike get(@PathVariable("id") long id) { return new Bike(); } }
[Spring Boot ] Creating the Spring Boot Project : Demo: Creating a REST Controller
标签:ota bind variable pos create tco ram spring end
原文地址:https://www.cnblogs.com/Answer1215/p/9609995.html