日期:2014-05-16  浏览次数:20673 次

Class org.apache.struts2.json.JSONWriter can not access a member of *

异常形式:

Class org.apache.struts2.json.JSONWriter can not access a member of *?或是?Class com.googlecode.jsonplugin.JSONWriter can not access a member of class*

第一种是struct2.1.8json结合时的异常,第二种是struct2.1.6json结合的异常。

?

具体:

Class org.apache.struts2.json.JSONWriter can not access a member of class oracle.jdbc.driver.BaseResultSet with modifiers "public"

?

解释:

不能把程序中的某种数据结构串行化成json格式。

?

原因:

struts2action里面的数据转换成json数据时,会将提供了get方法的属性都串行化输出JSON到客户端。有的时候,很多属性并不能串行化成json数据,比如这里的oracle.jdbc.driver.BaseResultSet。这时还进行强行转换就会出现这样的异常。

?

解决方法:

在不能串行化到json的属性相应的get方法前加一条json标记?@JSON(serialize=false)。告诉json不需要转化这个属性。或者根本不写这个get方法。

?

后记: