標籤: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
關鍵代碼
<% 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類型資料