读取HttpServeltRequest的请求参数-IO流-servlet

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/big1989wmf/article/details/84492117
--以流的形式读取HttpServletRequest的内容

protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String logStr=this.getClass().getName()+"."+Thread.currentThread().getStackTrace()[1].getMethodName()+"...";
logger.info(logStr+"调用post方法开始");
BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream(), "utf-8"));
//获取请求参数
StringBuffer sb = new StringBuffer("");
String temp=null;
while ((temp = br.readLine()) != null) {
sb.append(temp);
}
String inputParamsJsonString = sb.toString();
logger.info(logStr+"inputParamsJsonString=" + inputParamsJsonString);
}
展开阅读全文

没有更多推荐了,返回首页