Class com. googlecode. jsonplugin. jsonwriter can not access a member of class *

Source: Internet
Author: User

Exception format:

Class org. Apache. struts2.json. jsonwriter can not access a member of * or class com. googlecode. jsonplugin. jsonwriter can not access a member of class *

The first is the exception when struct2.1.8 is combined with JSON, and the second is the exception when struct2.1.6 is combined with JSON.

 

Details:

Class org. Apache. struts2.json. jsonwriter can not access a member of class oracle. JDBC. Driver. baseresultset with modifiers "public"

 

Explanation:

A Data Structure in a program cannot be serialized into JSON format.

 

Cause:

When the data in the struts2 action is converted to JSON data, the get method attributes are serialized and output to the client.Sometimes, many attributes cannot be serializedJSONData,For example, Oracle. JDBC. Driver. baseresultset. In this case, such an exception occurs when the conversion is forced.

 

Solution:

Add a JSON mark @ JSON (serialize = false) before the get method corresponding to the property that cannot be serialized to JSON ). This indicates that JSON does not need to be converted. Or do not write this get method at all.

 

Postscript:

The same method can be used to process JSON data that does not need to be output at the front end, thus reducing the amount of information for interaction between the server and the client.

You can add @ JSON (name = "status") before the get method of the attribute to be output at the front end to create an alias for this attribute, in the foreground, you can use status as the attribute name to read its value.

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.