Class org.apache.struts2.json.JSONWriter can not access a member of
2016-05-28 16:07
671 查看
异常形式:
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作为属性名来读取其值。
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作为属性名来读取其值。
相关文章推荐
- SVN版本管理系统的安装 CentOS + Subversion + Apache + Jsvnadmin
- Maven:程序包org.apache.log4j不存在问题处理
- linux 安装apache 错误:configure: error: /bin/sh build/config.sub failed解决办法
- Apache:BeanUtils和PropertyUtils的区别
- Apache Curator入门实战
- Apache服务器配置
- Apache jar包总结
- Apache服务器最新版下载、安装及配置(win版
- PHP + APACHE 智能安装(别整那些没用的了)
- ubuntu下配置apache多端口网站
- Apache提示You don't have permission to access / on this server问题解决
- Apache中如何设置默认首页具体该怎么操作
- 微信开发之SVN提交代码与FTP同步到apache的根目录
- Apache shiro 登录验证授权管理
- Apache服务器最新版下载、安装及配置(win版)
- apache、CDH、HDP hadoop源码下载
- apache 配置虚拟目录+默认页+隐藏index.php
- 编译安装 apache2.4.12
- CentOS下Apache开启Rewrite功能
- 【Apache】从Apache官网下载windows版apache服务器,并用AB进行压力测试