• 异步回调获取url请求的参数


    提供一个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

  • 相关阅读:
    Android 自定义title样式
    HDU 3094 A tree game 树删边游戏
    设计模式学习笔记观察者模式
    [Unity-7] Update和FixedUpdate
    一淘搜索网页抓取系统的分析与实现(3)—scrapy+webkit &amp; mysql+django
    POJ 1947 树DP获得冠军
    linux 下一个 jira-6.3.6 组态 皴 翻译 迁移数据库
    阐述linux IPC(五岁以下儿童):system V共享内存
    使用OpenCV玩家营造出一个视频控制(没有声音)
    Swift编程语言学习4.1——周期
  • 原文地址:https://www.cnblogs.com/xint/p/9037455.html
Copyright © 2020-2023  润新知