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