提交application/x-www-form-urlencoded類型資料

來源:互聯網
上載者:User

標籤:multipart

提交application/x-www-form-urlencoded類型資料

發送application/x-www-form-urlencoded接收通知

舉例: 發送通知以及接收通知

說明:此demo非常簡化,使用tomcat伺服器運行,本文說明:

  • 包含檔案
    1.SendNotification.jsp:發送通知頁面,表單提交資料的類型為multipart/x-www-form-urlencoded
    2.RecvNotification.jsp:接收通知頁面
    3.頁面簡單使用了Bootstrap樣式
  • 接收參數方式 :request.getParameter(“param”);
Demo:

http://download.csdn.net/detail/musuny/8761707

關鍵代碼
  • SendNotification.jsp

    <form action="RecvNotification.jsp" method="post" enctype="application/x-www-form-urlencoded"><table class="table-responsive">    <tr>        <td>            <span>message:</span>            <textarea  rows="5" class="form-control" name="message" id="message" content=""                       placeholder="例如:PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8%2BPE1vQmFvQWNjb3VudCBNZXNzYWdlVHlwZT0iTm90aWZ5UGF5UmVzdWx0Ij48T3JkZXJObz5NMjAxNTA1NTYwOTg4MzY8L09yZGVyTm8%2BPFRyYWRlQW10PjUwMDAuMDA8L1RyYWRlQW10PjxDdXN0UGFyYW0%2BMTIzPC9DdXN0UGFyYW0%2BPFRyYWRlVGltZT48L1RyYWRlVGltZT48L01vQmFvQWNjb3VudD4="></textarea>            <br/>        </td>    </tr>    <tr>        <td>            <span>signature:</span>            <textarea  class="form-control" rows="5" name="signature" id="signature"                   placeholder="例如:33D13212133895FB6AF9C1556948996AC4A636F6A98E1E9DDE6296D0179E7466BF04C44F97EA3E6A29B69FED16C36C14BD8BFAFCB04806579573DC2F560DDB9820B4CC242038B33BC444C2C143D76EA9AD4F8F824EB9D1B5963DC867AA8B0C11D5B7A2D981151642E6DEDA845D94D9731ECD42E668AEA0D7EDD00C5817EF5DE8"                    content=""></textarea>            <br/>        </td>    </tr></table><input type="button" onclick="setDefaultValue()" style="margin-left: 200px;" value="使用預設值" class="btn-lg btn-success"/><input type="submit" value="類比發送通知" style="margin-left: 200px;" class="btn-lg btn-danger"/></form>
  • RecvNotification.jsp

<%    String ip = request.getHeader("X-Forwarded-For");    if (ip == null)        ip = request.getRemoteHost();    Map param = new HashMap();    param.put("ip", ip);    String message = request.getParameter("message");    param.put("message", message);    String signature = request.getParameter("signature");    param.put("signature", signature);    String messageDecode = URLDecoder.decode(message, "UTF-8");    String base64decoded = new String(new BASE64Decoder().decodeBuffer(messageDecode), "GBK");    param.put("base64decoded", base64decoded);    request.setAttribute("notification", param);    Map notification = (Map) request.getAttribute("notification");%><h2>接收到的支付通知訊息</h2><div class="table-responsive">    <table border="1" class="table table-bordered table-hover">        <thead>        <td class="col-lg-1 ">欄位名</td>        <td class="col-lg-6 ">接收到的值</td>        <td class="col-lg-3 ">說明</td>        </thead>        <tr>            <td class="col-lg-1 ">IP地址</td>            <td class="col-lg-6 "><%=notification.get("ip")%>            </td>            <td class="col-lg-3 ">支付通知方IP地址</td>        </tr>        <tr>            <td class="col-lg-1 ">message</td>            <td class="col-lg-6 "><textarea rows="5" class="form-control" cols="300" readonly><%=notification.get("message")%></textarea>            </td>            <td class="col-lg-3 ">message經過base64編碼以及URLEncode UTF-8編碼</td>        </tr>        <tr>            <td class="col-lg-1 ">message明文</td>            <td class="col-lg-6 "><textarea rows="5" class="form-control" cols="300" readonly><%=notification.get("base64decoded")%></textarea>            </td>            <td class="col-lg-3 ">message經過base64解碼以及URLEncode UTF-8解碼</td>        </tr>        <tr>            <td class="col-lg-1">signature</td>            <td class="col-lg-6 "><textarea rows="5" class="form-control" cols="300" readonly><%=notification.get("signature")%></textarea>            </td>            <td class="col-lg-3 ">簽名資訊</td>        </tr>    </table></div>
我的連絡方式
  • Q Q:1250052380
  • 郵箱:[email protected]

提交application/x-www-form-urlencoded類型資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.