1、@PathVariable
从url中获取参数,格式如下,url遵循restful的访问规则。
@RequestMapping(value = {"/dog/{id}"} , method = RequestMethod.GET) public String dog(@PathVariable("id") int id){
2、@RequestParam
从url中获取参数,格式如下,参数以问号的方式传递,可以设置是否必须要传递这个参数以及参数的默认值
@RequestMapping(value = {"/dog"} , method = RequestMethod.GET)public String dog(@RequestParam(value = "id" , required = false , defaultValue = "0") int id){