1:
/**
* 从客户端传来的请求流中获得请求参数
* @param request
* @return String
*/
public static String getParamByStream(HttpServletRequest request){
String param = \"\";
InputStream is = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
StringBuffer sb = new StringBuffer();
is = request.getInputStream();
isr = new InputStreamReader(is, \"UTF-8\");
br = new BufferedReader(isr);
String s = \"\";
while ((s = br.readLine()) != null) {
sb.append(s);
}
param = sb.toString();
param = URLDecoder.decode(param, \"UTF-8\");
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (br != null) {
br.close();
}
if (isr != null) {
isr.close();
}
if (is != null) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return param;
}
继续阅读与本文标签相同的文章
下一篇 :
JAVA 双亲委派机制
-
数据库基础技术实践#网络安全基础技术实践课程
2026-05-18栏目: 教程
-
MySQL每组求最值的记录与每组前N条记录
2026-05-18栏目: 教程
-
OCP-052考试题库汇总(55)-CUUG内部解答版
2026-05-18栏目: 教程
-
【云栖活动】架构师、产品经理一对一座谈会/WORKSHOP-已截止
2026-05-18栏目: 教程
-
MySQL入门书籍和方法分享
2026-05-18栏目: 教程
