前后台传参汇总

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);
    }
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1.什么是http协议? http协议是超文本传送协议,是客户端与服务器端间请求与响应的一套标准,即规则与格式。 ...
    润桦阅读 3,465评论 0 1
  • 1.GET请求 参数传递方式为JSON后端接收方式 可以通过注解required来设置是否必传 @RequestP...
    _花阅读 3,836评论 0 1
  • 声明:面试是对自我审视的一种过程,面试题和iOS程序员本身技术水平没有对等关联,无论你能否全部答出,都不要对自己产...
    Kevin_wzx阅读 6,689评论 1 2
  • 目录 算法 冒泡排序 网络通信协议TCP和UDP的区别 注册广播有几种方式,他们的区别是什么? Get请求和Pos...
    Jsonzhang阅读 2,844评论 0 3
  • 大纲 Java 基础 1. ==、equals 和 hashCode 的区别 == 用于基础数据类型的判断时,比较...
    Parallel_Lines阅读 5,397评论 0 2

友情链接更多精彩内容