• REST(Representational State Transfer)

    • 传统风格资源描述形式:

      http://localhost/user/getById?id=1

      http://localhost/user/saveUser

    • REST风格描述形式

      http://localhost/user/1

      http://localhost/user

  • 优点:

    1. 隐藏资源的访问行为,无法通过地址得知对资源是何种操作
    2. 书写简化
  • REST风格使用行为动作区分对资源进行了何种操作

    • http://localhost/users 查询所有用户信息(GET)
    • http://localhost/user/1 查询指定用户的信息(GET)
    • http://localhost/users 添加用户信息(POST)
    • http://localhost/users 修改用户信息(PUT)
    • http://localhost/user/1 删除用户信息(DELETE)

根据REST风格对资源进行访问称作restful

接收请求例:

@GetMapping("/getUserByName/{name}")
@ResponseBody
public ResultVo getUserByName(@PathVariable  String name){
  return uerService.getUserByName(name);
}