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.8与json结合时的异常,第二种是struct2.1.6与json结合的异常。

 

具体:

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

 

解释:

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

 

原因:

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

 

解决方法:

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

 

后记:

对于不需要在前台输出的json数据,也可以用同样的方法进行处理,从而减少服务器和客户端间交互的信息量。

可在需要在前台输出的属性的get方法前加上@JSON(name="status")标识,从而为该属性起了一个别名,在前台就可以通过status作为属性名来读取其值。

目录
相关文章
|
4天前
|
Dubbo Java 应用服务中间件
Serialized class org.apache.catalina.core.ApplicationPart must implement java.io.Serializable
Serialized class org.apache.catalina.core.ApplicationPart must implement java.io.Serializable
55 0
|
3天前
【Vetur找不到package.json和tsconfig.json】Vetur can‘t find ‘package.json’ / ‘tsconfig.json‘ in xxxx的解决方法
【Vetur找不到package.json和tsconfig.json】Vetur can‘t find ‘package.json’ / ‘tsconfig.json‘ in xxxx的解决方法
11 3
|
7月前
Can not set final java.lang.Class field org.apache.ibatis.binding.MapperProxy.mapperInterface to com
Can not set final java.lang.Class field org.apache.ibatis.binding.MapperProxy.mapperInterface to com
62 0
|
8月前
|
Apache Windows
(MAC) Apache You don't have permission to access / on this server.
(MAC) Apache You don't have permission to access / on this server.
46 0
|
11月前
|
Java Maven
Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log 解决方法
org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Jdk14Logger does not implement Log at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:400) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.jav
179 0
|
12月前
|
算法 Shell Apache
Apache ZooKeeper - ZK的ACL权限控制( Access Control List )
Apache ZooKeeper - ZK的ACL权限控制( Access Control List )
294 0
|
关系型数据库 MySQL Apache
Service Apache can not start. Reason:(OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一-次。: AH00072: make_ sock
Service Apache can not start. Reason:(OS 10048)通常每个套接字地址(协议/网络地址/端口)只允许使用一-次。: AH00072: make_ sock
158 0
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found
Cause: the class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found
93 0
|
Java Apache
Cause: the class org.apache.tools.ant.taskdefs.optional.ANTLR was not found.
Cause: the class org.apache.tools.ant.taskdefs.optional.ANTLR was not found.
86 0
|
JSON 数据格式 Python
python编程:json indent can't multiply sequence by non-int of type 'str'
python编程:json indent can't multiply sequence by non-int of type 'str'
118 0

热门文章

最新文章

推荐镜像

更多