SpringMVC的常用操作汇总

基本操作

#类级别的注解

       @Controller

       @RestController

       @RequestMapping("/hello")

 

#springMVC常用方法级别注解

       @ResponseBody

       @GetMapping()

       @GetMapping("/treeData")

       @GetMapping("/add/{parentId}")

       @GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })

      

       @PostMapping("/list")

       @PostMapping("/checkRoleKeyUnique")

      

       @DeleteMapping("/{userId}")

      

       @PutMapping("/update")

 

参数级别的

       @PathVariable("deptId") Long deptId

       @PathVariable(value = "excludeId", required = false) Long excludeId

       @PathVariable(value = "excludeId", required = false) String excludeId

      

       @Validated

      

       @Validated在controller层打在形参上,开启了jr303校验,校验字段在实体类字段

       视图在解析参数时会执行校验

 

 

 

中级操作 

  get请求,携带的参数是数组的情况

     

 

 

 

 

 

 

 

高级一点的

 

 

posted @ 2021-01-23 22:17  乙侍  阅读(100)  评论(0编辑  收藏  举报