您的位置:首页 > 运维架构 > Apache

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

2016-01-30 20:27 786 查看
在使用struts2向客户端输出数据的时候,出现错误:

<li>Class org.apache.struts2.json.JSONWriter can not access a member of class org.springframework.aop.interceptor.ExposeInvocationInterceptor$1 with modifiers "public"</li>↵                        <li>java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class org.springframework.aop.interceptor.ExposeInvocationInterceptor$1 with modifiers "public"</li>↵                        <li>org.apache.struts2.json.JSONException: java.lang.IllegalAccessException: Class org.apache.struts2.json.JSONWriter can not access a member of class


经检测,发现struts2通过ajax返回data的时候,会默认将Action中所有提供getter 的成员属性都序列化,如果有不能序列化的对象,则报错。

解决方法:

1,使用注解注释service,去掉getter

2,get***方法前面加入:@JSON(serialize=false)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: