Org. apache. struts2.json. JSONWritercannotaccessamembero

Source: Internet
Author: User
Exception format: Classorg. apache. struts2.json. JSONWritercannotaccessamemberof * or Classcom. googlecode. jsonplugin. JSONWritercannotaccessamemberofclass * 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.

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 in the combination of struct2.1.8 and json, and the second is the exception in the combination of struct2.1.6 and json.

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 serialized into json data, 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.