Development environment: spring-mvc4.1.7, fastjson1.2.7
Problem Description: The system adopts the full separation of the front and back end, the front-end page uses Ajax to invoke the background service, want to use Fastjson automatic conversion request Parameter object.
Front-end invocation
"Bas/test.do""POST"true"Application/json; Charset=utf-8 "function(RST) {alert (json.stringify (RST));}
@ResponseBody 2 @RequestMapping (value = "/add.do", method = {requestmethod.post, requestmethod.get}, produces = "application/ Json;charset=utf-8 ") 3 public void add (@RequestBody country Country) { 4 // ... 5 }
Run the error stack as follows:
for Servlets [SPRINGMVC] in the context with path [/MFD] threw exception [Request processing failed; nested exception Is Com.alibaba.fastjson.JSONException:syntax error, expect {, actual error, POS 00 at Com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze (Javabeandeserializer.java:232)
Search for various solutions on the Web The result of the last attempt to convert the JSON object into a JSON string was successfully called.
Modified to Data:JSON.stringify (country)
When using Jackson on the previous project, the data parameter passed directly to the JSON object, which is not supported by Fastjson ...
Fastjson Automatic conversion parameter error