在使用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)