req.setCharacterEncoding("utf-8");
//处理应答乱码
resp.setContentType("text/html;charset=utf-8");
//...
BufferedReader br = req.getReader();
String str, wholeStr = "";
while((str = br.readLine()) != null){
wholeStr += str;
}
JSONObject jsStr = JSONObject.fromObject(wholeStr);
JSONObject jsStr1 = JSONObject.fromObject(jsStr.get("data"));
String username = jsStr1.get("username").toString();
String password = jsStr1.get("password").toString();
用读流类的方式,读取出body中data的全部数据。