<form id="receipt">
<%
HashMap params = new HashMap();
Enumeration paramsEnum = request.getParameterNames();
while (paramsEnum.hasMoreElements()) {
String paramName = (String) paramsEnum.nextElement();
String paramValue = request.getParameter(paramName);
params.put(paramName, paramValue);
out.print("<span>" + paramName + "</span><input type=\"text\" name=\"" + paramName + "\" size=\"50\" value=\"" + paramValue + "\" readonly=\"true\"/><br/>");
}
我已在响应页面中将此代码编写在cybersource设置中链接此页面。但它给出的空值并不能归还任何东西。但我收到邮件的全部付款细节。我怎么能得到它?
答案 0 :(得分:0)
您可以在显示所有参数之前添加空检查,并且您不需要创建HashMap,Enumaration接口可帮助您迭代并显示参数和值。
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ page import="java.util.Enumeration"%>
<%
request.setCharacterEncoding("UTF-8");
Enumeration<String> params = request.getParameterNames();
if (params == null) {
out.println("Parameters are empty");
return;
}
while (params.hasMoreElements()) {
String param = params.nextElement();
String paramValue = request.getParameter(param);
out.println(param + ": " + paramValue + "</br>");
}
%>