`
chinagdvea
  • 浏览: 126111 次
  • 性别: Icon_minigender_1
  • 来自: 韶关
社区版块
存档分类
最新评论

关于一个JSON异常

阅读更多
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException

出现原因:

    1、在返回JSON字符串的类中,其成员变量如果是由Spring注入的并提供了getter方法,则抛此异常。

    2、懒加载导致。

解决方案:

    1、Spring注入的方法只提供setter方法,不提供getter方法。

    2、排除hibernateLazyInitializer属性。在配置中把hibernateLazyInitializer属性除外:

    <result name="returnValue" type="json">
        <param name="excludeProperties">.*hibernateLazyInitializer</param>
    </result>
分享到:
评论
1 楼 skcmm 2011-09-01  
我现在遇到的问题 不清楚是哪种情况造成的  如果是第一种 @autowrite这种方式 怎样弄? 第二种的话 我的json action 也是用的注解 要怎样弄呢?:

相关推荐

Global site tag (gtag.js) - Google Analytics