1. 程式人生 > >獲取前臺傳遞信息

獲取前臺傳遞信息

str nts getjson rac string exceptio buffered req object

/**
     *  獲取前臺向URL傳遞的數據
     */
    // FIXME TODO XXX 獲取前臺傳遞的json字符串
    public void getJSONParam(HttpServletRequest request){
        JSONObject jsonParam = null;
        try {
            // 獲取輸入流
            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));

            
// 寫入數據到Stringbuilder StringBuilder sb = new StringBuilder(); String line = null; while ((line = streamReader.readLine()) != null) { sb.append(line); } // 直接將json信息打印出來 System.out.println(sb.toString()); } catch
(Exception e) { e.printStackTrace(); } }

獲取前臺傳遞信息