spring-boot-starter-web 使用教程
1. 引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2. 相关配置
server.port=8080
3. 控制器相关注解
控制器类注解:
@Controller
@RestController
@RequestMapping("path")
public class SomeController{}
3.1 Get 请求
@GetMapping("get/{id}")
public ResponseEntity<?> someMethod(@PathVariable String id){
}
3.2 Post 请求
@PostMapping("post")
public ResponseEntity<?> someMethod(@RequestBody Object requestBody){
}