最近使用curl命令调用服务进行测试,命令如下
curl -H 'Content-Type: application/json' -d '{"CHANCE_STATUS":"","GRP_ID":"","BUSI_REQ_CLASS":"","PAGE_NUM":1,"CREATE_NO":"","pageSize":"5","PROD_NAME":"","pageNum":"1","PROVINCE_GROUP":"10017","OPER_NO":"LZZZZZ110","CRM_TACHE_ID":"","PAGE_SIZE":5,"CHANCE_ID":"","CUST_NAME":""}' 'http://152.55.229.226:8888/saleCenter-app/rs/service/com_IQueryListSvc_selectQueryListForApp'
发现问题为,入参没有传进去,方法如下
接口方法为
String selectQueryListForApp(String inparam);
实现类为
@ResponseBody
@Override
public String selectQueryListForApp(String Str) {
System.out.println("===selectQueryListForApp==Str======"+Str);
Map inParam = (Map) JSONObject.parse(Str);
Map<String, Object> outPar = null;
outPar = iQueryListEntity.selectQueryLists(inParam);
JSONObject itemJSONObj = JSONObject.parseObject(JSON.toJSONString(outPar));
return itemJSONObj.toString();
}
打印后Str为null
解决办法
在实现类和方法的参数前,加@RequestBody,即
String selectQueryListForApp(@RequestBody String inparam);
public String selectQueryListForApp(@RequestBody String Str)
修改后,成功完成调用
@requestBody注解的使用
参考