获取值

江南北

关注

阅读 77

2022-11-04

1. Map<String, String> params = new HashMap<String, String>();

Map<String, String[]> paramsMap = request.getParameterMap();

for (Map.Entry<String, String[]> entry : paramsMap.entrySet()) {

params.put(entry.getKey(), entry.getValue()[0]);

}

2.String requestContent = SysUtil.InputStreamTOString(request.getInputStream());
public static String InputStreamTOString(InputStream in) throws Exception{
int BUFFER_SIZE = 4096;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] data = new byte[BUFFER_SIZE];
int count = -1;
while((count = in.read(data,0,BUFFER_SIZE)) != -1)
outStream.write(data, 0, count);


data = null;
return new String(outStream.toByteArray(),"UTF-8");
}

精彩评论(0)

0 0 举报