场景
请求参数需要传递如下类型的参数
{"TableName":"wms_receive_order","PrintID":["28"]}
实现
打开项目的pom.xml
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.24</version></dependency>
添加如下依赖并下载依赖包
来到后台Controller
导入jar包
import com.alibaba.fastjson.JSON;
使用
String param= JSON.toJSONString(map);
举例
@ResponseBody@RequestMapping(value = "/doPrintPostRequest")public Map<String, Object> doPrintPostRequest(@RequestBody Map<String, Object> params) {Map<String, Object> result = new HashMap<String, Object>();Object PrintId = params.get("id");String paramID="";if(PrintId!=null){paramID=PrintId.toString();}String URL="";Map map=new HashMap();map.put("TableName","wms_receive_order");List<Object> idList=new ArrayList<Object>();idList.add(paramID);map.put("PrintID",idList);String param= JSON.toJSONString(map);String message = HttpRequestUtil.sendPost(URL, param);result.put("statusCode", "200");result.put("message", message);return result;}