Commit 41ff0eb1 authored by zhangyong's avatar zhangyong

1

parent e4af8797
......@@ -81,6 +81,8 @@ public class StringUtil {
public static String join(String sign, String before, Collection<String> strs) {
return join(sign, before, "", strs.toArray(new String[strs.size()]));
}
/**
*
......@@ -1013,5 +1015,5 @@ public class StringUtil {
}
return "";
}
}
package com.egolm.common.web;
import java.net.InetAddress;
import java.net.URLDecoder;
import java.net.UnknownHostException;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import com.egolm.common.StringUtil;
import com.egolm.common.exception.PluginException;
public class ServletUtil {
......@@ -34,5 +37,36 @@ public class ServletUtil {
throw new PluginException(e);
}
}
/**
*
* @Description 读取传入的json字符
* @param request
* @return
* @return String
* @throws
* @author 曲欣亮
* @date 2016年5月17日
* @since 2016年5月17日
*/
public static String readReqJson(HttpServletRequest request) {
String json = "";
try {
Enumeration<?> names = request.getParameterNames();
if(names.hasMoreElements()) {
json = (String)names.nextElement();
}
if(json == null || json.length() == 0) {
json = StringUtil.read(request.getReader());
}
} catch (Exception e) {
e.printStackTrace();
}
try {
String encodeJson = URLDecoder.decode(json, "UTF-8");
return encodeJson;
} catch (Exception e) {
e.printStackTrace();
return json;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment