Update operation background
1 2 /**3 * Update Staff4 * @return"updatesdr"5 */6 publicString updatethesdr () {7Jsonstr = "{\" oid\ ":" +oid+ "}";8 Try {9 //gets the JSON data for the selected objectTenReturnsdrupdate =OABOSVC.GETTHESDR (jsonstr); one //convert to JSON object aJsonobject Jasonobject =Jsonobject.fromobject (returnsdrupdate); - //get the corresponding value from the JSON object OID name phone -OID =jasonobject.getstring ("oid"); theString name =jasonobject.getstring ("name"); -String phone =jasonobject.getstring ("phone"); -System.out.println ("pre-modification information:------>" + "oid:" +oid+ "," + "name:" +name+ "," + "phone:" +phone); - //creates a new object that takes the obtained value to the object +FORMVO =NewSdsdper (); - formvo.setname (name); + Formvo.setphone (phone); a at}Catch(Exception E) { - e.printstacktrace (); - } - return"updatesdr"; - } - /** in * Click OK to update the modification information - * @return to * @throwsException + */ - publicString updatesdrinfo () { the Try{ * //get the value of a page by Servelet $HttpServletRequest request=servletactioncontext.getrequest ();Panax NotoginsengName=request.getparameter ("formvo.name"); -Phone=request.getparameter ("formvo.phone"); the //Stitching JSON +Jsonstr = "{\" oid\ ":" +oid+ ", \" name\ ":" +name+ ", \" phone\ ":" +phone+ "}"; aSystem.out.println ("post-edit info:---->" +jsonstr); the //Calling Methods +Updatesdrinfo =OABOSVC.UPDATESDR (jsonstr); -Map map = (HashMap) Gsonutil.getobject (updatesdrinfo, HashMap.class); $ //Print Operation results $ System.out.println (map); -Success = (Boolean) Map.get ("success"); - Promptinfo (success); the } - Catch(Exception E) {WuyiLog.error ("...... ..... ..... ........................ ..." +e.getmessage (...) + "..." ..... ..... ..... ..... ... "); the e.printstacktrace (); - } wu return NULL; -}
Reference: conversion between Java and JS in jsonobject,jsonarray,map,string-continuous update
This article is for personal records only
Available for reference
2017-11-13 09:02:13
Update operation about JSON string concatenation, JSON string and JSON object conversion