今天在修改系統的一個Action類時(系統架構是struts2+spring+hibernate),報瞭如下錯誤:spring
JSONWriter can not access a member of class org.springframework.aop.TruePointcut with modifiers "public"json
後來發現是因爲我在該Action類中新增長了一個對象屬性,並添加了get和set方法,經過spring注入,但因爲該Action類使用了struts2支持的json格式字符串返回,會將我新增長的這個對象屬性也添加到返回的json字符串,致使struts2報錯,該錯誤的解決方法有2個:架構
1)在新增對象屬性的get方法上添加標註「@JSON(serialize=false)」;ide
2)去掉新增對象屬性的get方法;hibernate
這樣,在返回json格式字符串時,不會再添加這個對象屬性,也就不會再報錯了。對象