接口取值测试案例

@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());

猜你喜欢

转载自www.cnblogs.com/xueblvip/p/12956132.html
今日推荐