提供一个url,服务器回调这个url的时候能够获取传过来的参数

<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@page import="java.io.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>success</title>
</head>
<body>
<%
//http://101.201.38.47/egx/wxpay_notify_url.jsp
System.out.println("----进入到了该页面---");
BufferedReader reader = request.getReader();
String line = "";
StringBuffer inputString = new StringBuffer();
try {
while ((line = reader.readLine()) != null) {
inputString.append(line);
}
request.getReader().close();

//自己测试的这样可以获取到参数

// String version = request.getParameter("version");
System.out.println("----接收到的报文---" + inputString.toString());
JSONObject json = XmlUtil.XmlToJson(inputString.toString());
//String appid=json.get("appid")+"";
//String mch_id=json.get("mch_id")+"";
if (json.getString("return_code").equals("SUCCESS")) {
if (json.getString("result_code").equals("SUCCESS")) {
String transaction_id = json.get("transaction_id") + "";//微信支付订单号
String out_trade_no = json.get("out_trade_no") + "";//商户订单号
String openid = json.get("openid") + "";
String trade_type = json.get("trade_type") + "";
//接下来是做自己的业务处理
//开一个线程,更新订单状态
WXPayFinishThread wxp = new WXPayFinishThread(openid,
transaction_id, out_trade_no, trade_type);
wxp.start();

}
}
//告诉微信服务器,我收到信息了,不要在调用回调action了
response.getWriter()
.write("<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>");
System.out.println("----结束---" + inputString.toString());
} catch (Exception e) {
e.printStackTrace();
}
%>
success
</body>
</html>

 

转载的博文地址:https://blog.csdn.net/ytTea/article/details/51736776