@RequestMapping与@PostMapping等新注释的curd操作

---操作  /user  为例

1--增(Post)

@RequestMapping

@RequestMapping(value = "/user",method = RequestMethod.POST)

@PostMapping

@PostMapping("/user")
    public String insert() {
        System.out.println("用户新增");
        return "";
    }

2--删(Delete)

@RequestMapping

@RequestMapping(value = "/user",method = RequestMethod.DELETE)

@DeleteMapping

@DeleteMapping("/user")
    public String delete() {
        System.out.println("用户删除");
        return "";
    }

3--改(Put/Patch)

   put        -----       是对整体的修改

  patch     -----     是对局部的修改

@RequestMapping

@RequestMapping(value = "/user",method = RequestMethod.PUT)

@PutMapping

@PutMapping("/user")
    public String update() {
        System.out.println("用户更新");
        return "";
    }

@PatchMapping

@PtachMapping("/user")
    public String update() {
        System.out.println("用户更新");
        return "";
    }

 

4--查(Get)

@RequestMapping

@RequestMapping(value = "/user",method = RequestMethod.GET)

@GetMapping

@GetMapping("/user")
    public String select() {
        System.out.println("用户查询");
        return "";
    }

 

posted @ 2019-09-20 16:34  B1ack_Wall  阅读(1222)  评论(0编辑  收藏  举报