// 获取Body中的json字符串进行解析--------------------------------------------------------------
// 获取Request对象
HttpServletRequest request = ServletActionContext.getRequest();
StringBuffer sb = new StringBuffer();
try {
// json格式字符串
String jsonStr = "";
// 获取application/json格式数据,返回字符流
BufferedReader reader = request.getReader();
// 对字符流进行解析
while ((jsonStr = reader.readLine()) != null) {
sb.append(jsonStr);
}
} catch (IOException e) {
e.printStackTrace();
}
// 将json字符串(jsonStr)-->json对象(JSONObject)
JSONObject jo = JSONObject.fromObject(sb.toString()).getJSONObject("data");
System.out.println(jo);
String logis_no = jo.getString("logis_no"); //单号
String weight = jo.getString("weight"); //重量
String file = jo.getString("file"); //图片base64