RequestParameter
RequestMapping
@RequestMapping(value = "/ex/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoosBySimplePath(){
return "Get some Foos";
}簡單映射 A Simple Mapping (如何接到 QueryString 的參數)
@GetMapping("/api/foos")
@ResponseBody
public String getFoos(@RequestParam String id) {
return "ID: " + id;
}http://localhost:8080/api/foos?id=abc
----
ID: abc指定請求參數 Specifying the Request Parameter Name
製作可選的請求參數 Making an Optional Request Parameter
請求參數的默認值 A Default Value for the Request Parameter
映射所有參數 Mapping All Parameters
映射多值參數 Mapping a Multi-Value Parameter
@RequestParam vs @PathVariable
查詢參數 & URI路徑
編碼與精確值
可選值
Last updated