郑州企业网站设计,常用cms系统,用哪个网站做首页好,如何对现有的网站改版介绍大家都知道微信支付的回调链接要求不能跟参数#xff0c;但又要接收返回的xml数据。我开始使用RequestBody注解在参数上#xff0c;希望能获取xml数据#xff0c;测试失败。最后使用HttpServletRequest去获取数据成功了。示例代码RequestMapping(/weixinpay/callb…介绍大家都知道微信支付的回调链接要求不能跟参数但又要接收返回的xml数据。我开始使用RequestBody注解在参数上希望能获取xml数据测试失败。最后使用HttpServletRequest去获取数据成功了。示例代码RequestMapping(/weixinpay/callback)public String callBack(HttpServletRequest request){InputStream is request.getInputStream();String xml StreamUtil.inputStream2String(is, UTF-8)/*** 后面把xml转成Map根据数据作逻辑处理*/}/*** InputStream流转换成String字符串* param inStream InputStream流* param encoding 编码格式* return String字符串*/public static String inputStream2String(InputStream inStream, String encoding){String result null;try {if(inStream ! null){ByteArrayOutputStream outStream new ByteArrayOutputStream();byte[] tempBytes new byte[_buffer_size];int count -1;while((count inStream.read(tempBytes, 0, _buffer_size)) ! -1){outStream.write(tempBytes, 0, count);}tempBytes null;outStream.flush();result new String(outStream.toByteArray(), encoding);}} catch (Exception e) {result null;}return result;}总结以上就是这篇文章的全部内容了希望能对大家的学习或者工作带来一定的帮助如果有疑问大家可以留言交流。