Spring MVC 接收参数的方式
🏷️ Spring MVC
1. @RequestBody
POST 参数
java
@RequestMapping(value = "/Search", method = RequestMethod.POST)
public final List<Model> Search(@RequestBody SearchCondition condition) {
}
2. @PathVariable
URL 中的参数 @RequestMapping
参数中需要使用占位符
java
@RequestMapping(value = "/Search/{key}", method = RequestMethod.GET)
public final Result Search(@PathVariable String key) {
}
3. @RequestParam
接收 PostBody 中或者 Url 中的 QueryString
java
@RequestMapping(value = "/Search", method = RequestMethod.POST)
public final Result Search(@RequestParam("key") String key) {
}