美文网首页
前后台传参汇总

前后台传参汇总

作者: _借东西的小人 | 来源:发表于2023-06-12 09:24 被阅读0次

    1.get请求传id

    前台传递

    export function delBlueprint(id) {
      return request({
        url: '/blueprint/blueprint/' + id,
        method: 'get'
      })
    }
    

    后台接收

      @GetMapping(value = "/{id}")
        public AjaxResult getInfo(@PathVariable("id") Integer id) {
        }
    

    2.get请求传对象

    前台传递

    export function listBlueprintCheck(query) {
      return request({
        url: '/blueprint/blueprint/checkList',
        method: 'get',
        params: query
      })
    }
    

    后台接收

       @GetMapping("/checkList")
        public AjaxResult checkList(EngBlueprint engBlueprint) {
            try {
                startPage();
                List<Map<String,Object>> list = engBlueprintService.selectEngBlueprintCheckList(engBlueprint);
                return AjaxResult.success("查询成功", getDataTable(list));
            } catch (Exception e) {
                return AjaxResult.error(e.getMessage());
            }
    
        }
    

    3.传集合对象(get,post类似)

    前台传递

    export function listBlueprintCheck(query) {
      return request({
        url: '/blueprint/blueprint/checkList',
        method: 'get',
        params: query
      })
    }
    

    后台接收

        @GetMapping
        public AjaxResult add(@RequestBody Map<String, Object> map) {
    
    //        User  user = JSON.parseObject(JSON.toJSONString(map.get("form")), user .class);
    //        List<HashMap<String, String>> list = (List<HashMap<String, String>>) map.get("list");
    //        for (HashMap<String, String> hashMap : list) {
    //            User user = JSON.parseObject(JSON.toJSONString(hashMap), User.class);
    //        }
        }
    

    4.post请求传id

    前台传递

    export function resetCipher(id) {
      return request({
        url: '/user/resetCipher',
        method: 'post',
        id
      })
    }
    

    前台传递

    @PostMapping("/xxx")
    public AjaxResult resetCipher(@RequestBody String id) {
           Integer.parseInt(id);
        }
    

    相关文章

      网友评论

          本文标题:前后台传参汇总

          本文链接:https://www.haomeiwen.com/subject/lhcqmrtx.html