request.getInputStream中文乱码解决方案


final_request.setCharacterEncoding("UTF-8");
  StringBuilder buffer = new StringBuilder();
  BufferedReader reader=null;
  try{
   reader = new BufferedReader(new InputStreamReader(final_request.getInputStream(),"UTF-8"));
   String line=null;
   while((line = reader.readLine())!=null){
    buffer.append(line);
         }
  }catch(Exception e){
   e.printStackTrace();
  }finally{
   if(null!=reader){
    try {
     reader.close();
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
  }
buffer.toString()

你可能感兴趣的:(Java,web)