controller 接收json

@ResponseBody
@RequestMapping(value = “/request/data”, method = RequestMethod.POST, produces = “application/json;charset=UTF-8”)
public String getByRequest(HttpServletRequest request) {

    //获取到JSONObject
    JSONObject jsonParam = this.getJSONParam(request);

    // 将获取的json数据封装一层,然后在给返回
    JSONObject result = new JSONObject();

    result.put("msg", "ok");
    result.put("method", "request");
    result.put("data", jsonParam);
    System.out.print(result);
    return result.toJSONString();
}

public JSONObject getJSONParam(HttpServletRequest request){
JSONObject jsonParam = null;
try {
// 获取输入流
BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), “UTF-8”));

        // 写入数据到Stringbuilder
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = streamReader.readLine()) != null) {
            sb.append(line);
        }
        jsonParam = JSONObject.parseObject(sb.toString());
        // 直接将json信息打印出来
        System.out.println(jsonParam.toJSONString());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return jsonParam;
}

测试地址:http://qq1012822599.cn:8888/findAllLog
QQ:1012822599 跳过安全效验(java,python)
自动登录,无需扫码和输入用户名、密码
1、全天候 7*24 自动监控收款,自动将即时到帐的交易反馈到网站接口或者数据库
2、轻松实现支付宝即时到账接口的功能,省去了人工一一对账再加款操作的麻烦
3、成功地解决了中、小企业及非企业支付,手续费昂贵等问题
在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述
测试地址:http://qq1012822599.cn:8888/findAllLog
QQ:1012822599

发布了71 篇原创文章 · 获赞 7 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_35577329/article/details/103389214