在使用json的时候,产生的一个错误,查了一下资料,原来是struts2和json一起使用的时候,才产生的问题,虽然不影响程序的运行,但是总是会有一些异常的日志产生,并且,这个也会增加程序的负担。

原因:

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

我的代码:

    private static final long serialVersionUID = 1L;
private Logger logger=Logger.getLogger(AuthAction.class);
private AuthService authService;
private RoleService roleService;
private HttpServletRequest request;
private HttpServletResponse response; private int authId;
private String authName;
private String authPath;
private int parentId;
private String authDesc;

在action里面,我要输出到页面的是第二段里面的authid等字段,上面的一段代码中,通过spring,注入了authService 和 roleService,并且都有get方法。

解决方法:

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

因为用的是setter-getter方式注入,不能不写get方法,就在下面两个getXXXService方法前加上 @JSON(serialize=false) ,这样控制台就不会报错了,也减少了json输出时候的负担。

解决json结合struts2时,Class org.apache.struts2.json.JSONWriter can not access a member of * 的问题的更多相关文章

  1. Class org.apache.struts2.json.JSONWriter can not access a member of class org.springframework.aop.TruePointcut with modifiers "public"

    Spring注入Action使用Json错误:org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: ...

  2. 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. ...

  3. org.apache.struts2.json.JSONWriter can not access a member of class

    偶遇一个问题:org.apache.struts2.json.JSONWriter can not access a member of class org.apache.tomcat.dbcp.db ...

  4. Class org.apache.struts2.json.JSONWriter can not access a member of class oracle.jdbc.driver.Physica

    产生这个错误的原因是因为我的oracle数据库中有一个CLOB字段,查询出来的时候要转换为JSON而报错. Class org.apache.struts2.json.JSONWriter can n ...

  5. Struts2 项目 Action 查询结果异常 org.apache.struts2.json.JSONException

    问题描述 今天进行一个订单管理模块的开发时遇到一个问题:查询的订单时有时会报这个异常: org.apache.struts2.json.JSONException: java.lang.Illegal ...

  6. 第一次部署Struts2时出现错误java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.class

    报如下错误 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org. ...

  7. 转载:Struts2+Jquery实现ajax并返回json类型数据

    摘要: 主要实现步骤如下: 1.JSP页面使用脚本代码执行ajax请求 2.Action中查询出需要返回的数据,并转换为json类型模式数据 3.配置struts.xml文件 4.页面脚本接受并处理数 ...

  8. json与java对象的转换,以及struts2对json的支持,实现ajax技术

    这两天学的东西有点多,今天抽个时间写下来,以此作为激励,这两天学了json,ajax,jQuery 一.使用第三方的工具java转换为json类型 首先就是java类型转换为json对象,首先要导入第 ...

  9. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter与org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

随机推荐

  1. java websocket @ServerEndpoint注解说明

    http://www.blogjava.net/qbna350816/archive/2016/07/24/431302.html https://segmentfault.com/q/1010000 ...

  2. Bootstrap-CL:略缩图

    ylbtech-Bootstrap-CL:略缩图 1.返回顶部 1. Bootstrap 缩略图 本章将讲解 Bootstrap 缩略图.大多数站点都需要在网格中布局图像.视频.文本等.Bootstr ...

  3. [Winform][C#]获取系统颜色预定义颜色和现有字体集

    转自: http://zhidao.baidu.com/link?url=ozY7tJRNBYHUsImE6jn1psqc8owib7MWcDMEmZw48q8iD9Hz9MWgnQQcBDO0VYO ...

  4. laravel下载文件

    public function jobDownload(){ $realPath = public_path('download/job/postForm.xls'); $filename = '应聘 ...

  5. Oracle VM Virtualbox基础知识

    修改硬盘的UUID VBoxManage internalcommands sethduuid <filename>

  6. 20181205_C#窗体监听键盘事件

    1. 需要设置窗体的   KeyPreview = true; 2. 如果窗体上有获取的了焦点的button按钮, 则监听不到 Enter事件, 需要取消按钮的焦点

  7. Oracle数据库物理结构

    Oracle数据库物理结构 oracle的数据,实际上是以文件的形式来保存的,文件中出了保存用户的数据之外,还需要保存管理数据和日志数据等等.作为一个DBA,必须需要知道自己的数据分别保存在什么位置上 ...

  8. RMAN非归档

    改变归档模式到非归档模式: 1)SQL>SHUTDOWN IMMEDIATE; 2)SQL>STARTUP MOUNT; 3)SQL>ALTER DATABASE NOARCHIVE ...

  9. canvas绘制曲线

    canvas绘制曲线 方法 quadraticCurveTo(cp1x, cp1y, x, y) 只有一个控制点的贝塞尔曲线(其实就是控制点分别与起始点和结束点连线的公切线) bezierCurveT ...

  10. mybatis 3 -枚举

    定义枚举: public static enum AppStateEnum { Valid("有效"), Virtual("虚拟"), Hide("隐 ...