美文网首页
POST方式传参类型

POST方式传参类型

作者: 墨色尘埃 | 来源:发表于2019-05-14 19:38 被阅读0次

POST方式

当以application/json方式传参时,可以是Integer 、Boolean、String 、集合

{
"ids": [
1122057516649189385,
1122057516649189384,
1122057516649189383
],
"subjectType": 1101,
"subjectid": "1120946621235015682",
"isnull":false
}

后台使用map接收的时候,类型同上。

image.png
    @RequestMapping(value = "/export", method = RequestMethod.POST)
    public ResponseObj<Page<SubjectEnrollCertDetail>> export(@RequestBody Map map) throws Exception {
        Page page = new Page();
        List<Long> list = (List<Long>) map.get("ids");
        Integer current = (Integer) map.get("current");
        Integer size = (Integer) map.get("size");
        Boolean isnull = (Boolean) map.get("isnull");

}

GET方式

GET请求方式,传的参数都在url中,所以都是String类型

如果以GET方式传入的参数过多的话,建议使用POST方式。  
众所周知,传递小量参数(在没有其他原因,例如隐藏参数值的情况下)推荐使用GET方法,传递大量参数推荐使用POST方法。原因是什么呢?

URL 长度有限制吗?

相关文章

网友评论

      本文标题:POST方式传参类型

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