Internal Server error Handling scheme when returning JSON string in SpringMVC3

Source: Internet
Author: User

After building the SPRING3+MYBATIS+REST+BOOTSTRAP+JBPM project environment, the test found a fucking problem.
When using spring MVC's automatic type conversion to JSON, background data list/map get completely normal, but JS gets the data report 500 error.
There is no exception information in the background.

Problem Solving Ideas:
The background data is working properly, the data returns to the front-end exception, and the problem is centered on the spring's Jackson JSON conversion.
And spring uses the third-party Jackson JSON data conversion, the exception information to rely on it, the code to add the following parts:

1 /**2 * Check all records of the bank3      * @paramreq4      * @paramModel5      * @return6      */7 @RequestMapping8 @ResponseBody9      PublicMap<string, object>Getallrecord (httpservletrequest req,Ten Modelmap model) { OneList<questionwh> allquestions =questionwhservice.selectallquestionwh (); AModel.put ("Aadata", allquestions); -Model.put ("Itotalrecords", Allquestions.size ()); -Model.put ("Itotaldisplayrecords", Allquestions.size ()); the          -         //testing The Jackson JSON transformation of the returned object -Objectmapper om =NewObjectmapper (); -         Try { + om.writevalueasstring (allquestions); -}Catch(jsongenerationexception e) { + e.printstacktrace (); A}Catch(jsonmappingexception e) { at e.printstacktrace (); -}Catch(IOException e) { - e.printstacktrace (); -         } -          -         returnmodel; in}

The exception message was successfully typed as follows:

 for class Java.io.ByteArrayInputStream and no properties discovered to create Beanserializer (to avoid exception, dis Able SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) (through reference chain:java.util.arraylist[0]-> java.util.hashmap["Createtime"]->oracle.sql.timestamp["Stream"])

The exception is found, the solution is very simple.

Internal Server error Handling scheme when returning JSON string in SpringMVC3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.