In the development project many times to encounter the foreground JS object in the background to transform the Java object, below for everyone to introduce the next front JS object to the background Java objects, interested friends can understand the next
The recent project development process, many times encountered the front desk JS object in the background to transform the Java object problem. Record the procedure to be used. In short, it is in the foreground with the Json.stringify () method of the JS object into a JS string, the background to receive the JSON string and convert it to JavaBean. Foreground code: The code is as follows: var data = {}; Data.id = $ (' #id '). Val (); data.msg = $ (' #msg '). Val (); Submit Data $.post (ContextPath + '/xxx.do? ') +new Date (). GetTime (), {data:JSON.stringify (data)},function (result) {alert (result); }); Background code: The code is as follows: @RequestMapping ("/xxx") public void Save (httpservletresponse response,string data) {if (! Stringutils.isempty (data) {//json string converted to JavaBean msg msg = (msg) jsonobject.tobean (data), Msg.class); ...} }