Prior to the integration of JSON with SSH has been found that the foreground does not get the JSON return data, directly run the action with the following error:
HTTP Status 500-org.apache.struts2.json.jsonexception:org.apache.struts2.json.jsonexception: Org.apache.struts2.json.JSONException:org.apache.struts2.json.JSONException: Org.apache.struts2.json.JSONException:java.lang.IllegalAccessException:Class Org.apache.struts2.json.JSONWriter Can not access a member of class Org.apache.commons.dbcp.poolingdatasource$poolguardconnectionwrapper with modifiers " Public The main reason: struts converts some of the variables defined in the action into JSON format, requiring a series of get methods to invoke the object (the example callsget method for Userdao), and call Get method for member variables of the above variablesMake its contents into JSON format. However, when serializing the Authorityservice, thethe member variable contains an interface, so it will be an error.。
The final reference to the online solution solved, but the process found some of the online statements have problems.
http://blog.csdn.net/xtra6714/article/details/5721593
This guy says that this error occurs when the method returns an interface type, removing the Get method for the associated return interface type in the action, but there is no way to return the interface type directly in my action!
http://hi.baidu.com/whosimplylol/item/bd93329d20884ccbb625315f
The explanations in this article are as follows:
Exception form:
Class Org.apache.struts2.json.JSONWriter can not access a member of * or class Com.googlecode.jsonplugin.JSONWriter can no T access a member of class*
The first is the exception when struct2.1.8 is combined with JSON, and the second is the exception that struct2.1.6 binds to JSON.
Specific:
Class Org.apache.struts2.json.JSONWriter can not access a member of class Oracle.jdbc.driver.BaseResultSet with modifiers "Public"
Explain:
You cannot serialize a data structure in a program into a JSON format.
Reason:
When the data in the Struts2 action is converted to JSON data, the properties that provide the Get method are serialized out JSON to the client. Sometimes, many properties are not serialized into JSON data, such as the oracle.jdbc.driver.BaseResultSet here. This exception occurs when a forced conversion is also made.
Workaround:
Add a JSON tag @JSON (serialize=false) before the corresponding get method for properties that cannot be serialized to JSON. tell JSON that you do not need to convert this property. Or do not write this get method at all.
Postscript:
For JSON data that does not need to be output in the foreground, it can be handled in the same way, reducing the amount of information that interacts between the server and the client.
You can use the @json (name= "status") identifier before the Get method of the property that you want to output in the foreground, which gives the property an alias, and the foreground can read its value by status as the property name.
Http://www.cnblogs.com/xiaoyaorensheng/archive/2013/01/02/2842302.html in this article is still more satisfactory, The Userdao member variable of the call has a GET method that returns the interface, so the JSON data cannot be returned.