URL映射
上节介绍介绍了@Controller和@RestController等注解,那么Spring Boot是如何将HTTP请求映射到具体方法的呢?Spring Boot支持URL路径匹配、HTTP Method匹配、params和header匹配等URL映射。本节开始介绍Spring Boot的URL映射。
1.URL路径匹配
1.1 精确匹配
@RequestMapping的value属性用于匹配URL映射,value支持简单表达式:
@RequestMapping("/getDataById/{id}")
public String getDataById(@PathVariable("id")