接口取值测试案例
作者:互联网
@RequestMapping(params="isexist") @ResponseBody @ApiOperation(value="sdss",produces="application/json",httpMethod="POST") public JSONObject isexist(String content,HttpServletRequest request) { String result = null; try { ServletInputStream inputStream = null; ByteArrayOutputStream outputStream = null; byte[] rs = new byte[1024]; inputStream = request.getInputStream(); outputStream = new ByteArrayOutputStream(); int len = 0; byte[] req = null; while ((len = inputStream.read(rs)) != -1) { outputStream.write(rs, 0, len); req = outputStream.toByteArray(); } result = new String(req, "UTF-8"); }catch (Exception e){ } JSONObject jsonObject =new JSONObject(); JSONArray jsonarray = new JSONArray(); String wheresql = ""; return jsonObject; }
调取接口
net.sf.json.JSONObject json1 = new net.sf.json.JSONObject(); json1.put("content", jsonArray2.toString()); JSONObject resp= JwtHttpUtil.httpRequest1(endpoint, "POST", json1.toString());
标签:outputStream,String,JSONObject,接口,案例,json1,new,null,取值 来源: https://www.cnblogs.com/xueblvip/p/12956132.html