首页 新闻 会员 周边

用restTemplate调用接口,参数有默认值,如果操作?

0
悬赏园豆:10 [已解决问题] 解决于 2020-10-26 20:38

用restTemplate调用接口,参数有默认值,如果操作?
比如,调用接口需要传入参数有count,type,但是type有默认值,那我想用type的默认值,我这种操作正确吗?
思路1:
JSONObject oj = new JSONObject();
oj.put("count","4");
oj.pt("type",null);

restTemplate.getForObject(url, JSONObject.class, oj);

思路2:
JSONObject oj = new JSONObject();
oj.put("count","4");

restTemplate.getForObject(url, JSONObject.class, oj);

这两种思路哪种正确?

lanto_liang的主页 lanto_liang | 初学一级 | 园豆:8
提问于:2020-10-15 20:01

建议改进一下排版,支持 markdown 语法

dudu 3年前

哎。。。没人回答

lanto_liang 3年前
< >
分享
最佳答案
1

这个类有其他方法支持强类型的,不一定都是JSONObject这一种对象
https://blog.csdn.net/itguangit/article/details/78825505 这里有几个例子

收获园豆:10
2012 | 高人七级 |园豆:21230 | 2020-10-16 08:30
其他回答(1)
0

可以的哦,嗯

lanto_liang | 园豆:8 (初学一级) | 2020-10-26 20:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册