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作为属性名来读取其值。

目录
相关文章
|
2月前
|
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
47 0
|
10月前
|
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
169 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
91 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.
83 0
|
分布式数据库 Hbase
报错:java.lang.RuntimeException: Failed construction of Regionserver: class org.apache.hadoop.hbase.re
报错:java.lang.RuntimeException: Failed construction of Regionserver: class org.apache.hadoop.hbase.re
233 0
|
Java 应用服务中间件 Maven
在idea中新建完springboot项目的时候遇到问题(右键没有class选择;控制台报错:Could not transfer artifact org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.60 from/to central ....)
在idea中新建完springboot项目的时候遇到问题(右键没有class选择;控制台报错:Could not transfer artifact org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.60 from/to central ....)
837 0
在idea中新建完springboot项目的时候遇到问题(右键没有class选择;控制台报错:Could not transfer artifact org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.60 from/to central ....)
|
JSON 数据格式
解决:Could not write JSON: No serializer found for class *** and no properties错误
解决:Could not write JSON: No serializer found for class *** and no properties错误
551 0
taskdef class org.apache.catalina.ant.InstallTask cannot be found
taskdef class org.apache.catalina.ant.InstallTask cannot be found
98 0
taskdef class org.apache.catalina.ant.InstallTask cannot be found
|
Apache
解决办法:Cannot find the class file for org.apache.http.client.ClientProtocolException
解决办法:Cannot find the class file for org.apache.http.client.ClientProtocolException
306 0
|
JSON JavaScript 前端开发
.NET 构造Class返回多个json值
  上次总结使用DataTable返回多个值,后来看到一个小哥的返回方式和我的有所不同,便留意了一下。原来他构造一个Class,而我构造的是一个Table。   首先说说两者的区别:拿student举例,student1有学号,姓名,成绩,student2,student3...都有该属性。
911 0

热门文章

最新文章

推荐镜像

更多