@Date:2022/4/17
**/
@RestController
@RequestMapping("/prefix")
public class ParaController {
@GetMapping({"/firstname"})
public String firstRequest() {
return “第一个spring boot接口”;
}
/**
- http://127.0.0.1:8080/prefix/firstnamepara?num=8(不能有空格)
- @param num
- @return
*/
@GetMapping({"/firstnamepara"})
public String requestPara(@RequestParam Integer num) {
return "para from request: " + num;
}
/**
- http://127.0.0.1:8080/prefix/para/5
- @param num
- @return
*/
@GetMapping({"/para/{num}"})
public String pathPara(@PathVariable Integer num) {
return "para from path : " + num;
}
@GetMapping({"/pairsUrl1/{num}" , “/pairsUrl2/{num}”})
public String pairsUrl(@PathVariable Integer num) {
return "para from path : " + num;
}
@GetMapping({"/required"})
public String required(@RequestParam(required = false,defaultValue = “1998”) Integer num) {
return "para from request: " + num;
}
}