zoukankan      html  css  js  c++  java
  • 获取post请求参数

    private String getBodyString(HttpServletRequest request) throws IOException {
                StringBuilder sb = new StringBuilder();
                InputStream inputStream = null;
                BufferedReader reader = null;
                try {
                    inputStream = request.getInputStream();
                    reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
                    String line = "";
                    while ((line = reader.readLine()) != null) {
                        sb.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    if (reader != null) {
                        try {
                            reader.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
                return sb.toString().trim();
            }
  • 相关阅读:
    list tuple dict 方法
    字典的方法
    看不懂的缩写
    canvas画图
    DOM2和DOM3
    表单脚本
    事件
    DOM扩展
    DOM
    BOM
  • 原文地址:https://www.cnblogs.com/syscn/p/12617578.html
Copyright © 2011-2022 走看看