读取 HttpServletRequest 中的流

/**
	 * 中天POST 方式 TODO 新增会员批量发送回调
	 * @param req
	 * @return
	 */
	@PostMapping("/rpt/smsStatusPullZTJH")
	public BaseResponse smsStatusPullZTJH(HttpServletRequest req, HttpServletResponse resp) {
		BaseResponse baseResponse = new BaseResponse();
		log.info("中天状态报告回调");
		BufferedReader br = null;
        String line = null;
        StringBuffer sb = new StringBuffer();
        try {
        	br = new BufferedReader(new InputStreamReader((ServletInputStream) req.getInputStream()));
			while ((line = br.readLine()) != null) {
			    sb.append(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
        String appMsg=sb.toString();
        log.info("状态报告={}" ,appMsg);

 打印的回调结果为:

状态报告=Status=Succ&Description=DELIVRD&FeeCount=3&GatewayId=2018111910581529350963&ServiceNo=10690994266400&Mobile=189145111&ReportTime=2018-11-19+10%3A58%3A19Status=Fail&Description=UNKNOWN&FeeCount=1&GatewayId=2018111619283929074119&ServiceNo=&Mobile=13121848041&ReportTime=2018-11-16+19%3A28%3A39Status=Succ&Description=DELIVRD&FeeCount=3&GatewayId=2018111910573329350609&ServiceNo=10690994266400&Mobile=18914511158&ReportTime=2018-11-19+10%3A57%3A37

 

你可能感兴趣的:(读取 HttpServletRequest 中的流)