使用就解析参数方法

master
jiahuiwen 2021-10-26 17:42:50 +08:00
parent 523dd0110b
commit e6ea389c7b
2 changed files with 14 additions and 1 deletions

View File

@ -36,7 +36,7 @@ public class HaoGameRechargeController {
@RequestMapping(value = "/haoGameCallback") @RequestMapping(value = "/haoGameCallback")
public String haoGameCallback(HttpServletRequest request) throws Exception { public String haoGameCallback(HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request); HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMapOld(request);
if (parameterMap.isEmpty()) { if (parameterMap.isEmpty()) {
LOGGER.info("data is null"); LOGGER.info("data is null");
return "data is null"; return "data is null";

View File

@ -70,6 +70,19 @@ public class JsonUtil {
return map; return map;
} }
public HashMap<String, String> getParameterMapOld(HttpServletRequest request) {
HashMap<String, String> map = new HashMap();
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String paramName = (String) paramNames.nextElement();
String[] paramValues = request.getParameterValues(paramName);
String paramValue = paramValues[0];
map.put(paramName, paramValue);
LOGGER.info("parameter : " + paramName + "=" + paramValue);
}
return map;
}
public static byte[] getRequestPostBytes(HttpServletRequest request) public static byte[] getRequestPostBytes(HttpServletRequest request)
throws IOException { throws IOException {
int contentLength = request.getContentLength(); int contentLength = request.getContentLength();