- url1: http://localhost:8080/findUser?name=tomcat&age=18
- url2: http://localhost:8080/findUser?name=tomcat&age=18&sex=男
需求: 上述的参数传递是否可以简化!
简化写法:
- url3: http://localhost:8080/findUser/tomcat/18/男
要求:
- restFul的风格数据的位置一旦确定,不能修改.
- 参数与参数之间使用"/"的方式分割.
- restFul的风格适用于 get/post/put/delete 请求类型
请求类型种类: get/post/put/delete
@RequestMapping("/findUser/{name}/{age}/{sex}")
public String findUser(@PathVariable String name,
@PathVariable int age,
@PathVariable String sex){
return name+":"+age+":"+sex;
}
效果



