Net.sf.json.JSONException:java.lang.NoSuchMethodException:Property ' name ' has no Getter Method__java

Source: Internet
Author: User

The source of the error:

JSON = Jsonobject.fromobject (t, jsonconfig). toString ();

Analysis: For diagram simplicity I write entity class user and test class in the same Java file.

The structure of my Code Testjson.java:

public class testjson{public
static void Main (string[] args) {
...
JSON = Jsonobject.fromobject (t, jsonconfig). toString ();
...
}

}
Class user{...
}

Parsing: Testjson.class files are generated when compiling Testjson.java files,
The user class is an internal class of the action class, and the Fromobject method searches the user class for the User.class by reflection mechanism, because the user class is an inner class, so the class is not found and there is no getter and setter method for the class attribute.
Solution: Extract the user class as a separate class.


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.