public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String s = request.getParameter("jsonDate");//ajax传递够来的json数据
response.setCharacterEncoding("utf-8");
JSONObject jsonObj = JSONObject.fromObject(s);//将json数据的字符串转换为JSONObject对象
Userinfo u = (Userinfo)JSONObject.toBean(jsonObj,Userinfo.class);//json对象转换成PO
boolean b = userService.update(u);
PrintWriter pw = response.getWriter();
if(b)
{
pw.write("记录更新成功");
}else
{
pw.write("记录更新失败");
}
pw.close();
}
将json数据格式的字符装装换成java对象(PO)
最新推荐文章于 2024-06-24 15:05:02 发布