var formData = json.stringify (this.rows); Convert data from a form to a string
$.ajax ({type:"Post", URL:'Http://localhost:8080/data', Data:formdata, DataType:"JSON", contentType: "application/json;charset=utf-8" , success:function (data) {}}); began to miss the Red property settings, resulting in the background is always unable to parse the data, can receive data, but very messy characters.
$.ajax http://www.runoob.com/jquery/ajax-ajax.html has many properties to set
@RequestMapping (value ="/data", method =requestmethod.post) Public voidgetData (@RequestBody String str) throws ioexception{Org.codehaus.jackson.map.ObjectMapper mapper=NewOrg.codehaus.jackson.map.ObjectMapper (); Javatype Javatype= Mapper.gettypefactory (). Constructparametrictype (ArrayList.class, Testmodel.class); List<TestModel> list = (list<testmodel>) Mapper.readvalue (str, javatype); System. out. println (str); System. out. println (list); }
There is one more question unresolved:
" /data ", method = requestmethod.post) publicvoid getData (@RequestBody list< Testmodel> list)
Unable to receive data to list
Spring MVC $.ajax does not specify ContentType, causing the background to not receive data