public static JSONObject json(){
String str ="";
try {
HttpServletRequest request=ServletActionContext.getRequest();
ServletInputStream sis = null;
request.setCharacterEncoding("UTF-8");
sis = request.getInputStream();
int len = request.getContentLength();
if (len <= 0) {
return null;
}
byte[] buffer = new byte[len];
sis.read(buffer);
str = new String(buffer, "UTF-8");
//sis.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//json 转 string
JSONObject jsonObject = JSONObject.parseObject(str);
return jsonObject;
}
java获取手机端JSON数据 并解析为字符串
最新推荐文章于 2018-03-16 14:25:24 发布