由于我使用Spring对项目进行重构,由Spring容器来管理Action,并为Action注入各种依赖,其中就有各个Service类,如CpAction对应的是CpService。
在applicationContext.xml中设置如下:
<bean id=”cpAction” >
<property name=”cpService” ref=”cpService”></property>
</bean>
<bean id=”cpService”
class=”cn.ricki.cheung.service.CpService”
parent=”baseService”>
</bean>
在Struts.xml中设置如下:
<action name=”CpAction” class=”cpAction”>
<result type=”json”/>
</action>
在CpAction中添加了cpService属性及其get/set方法。
登录网站,选择CP模块,报:org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException异常。
因为没有修改多少,所以我猜应该是cpService的get方法没有加上@JSON(serialize=false)注释引起了,加上该注释后,重新启动服务打开CP模块,一切正常。
在applicationContext.xml中设置如下:
<bean id=”cpAction” >
<property name=”cpService” ref=”cpService”></property>
</bean>
<bean id=”cpService”
class=”cn.ricki.cheung.service.CpService”
parent=”baseService”>
</bean>
在Struts.xml中设置如下:
<action name=”CpAction” class=”cpAction”>
<result type=”json”/>
</action>
在CpAction中添加了cpService属性及其get/set方法。
登录网站,选择CP模块,报:org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException异常。
因为没有修改多少,所以我猜应该是cpService的get方法没有加上@JSON(serialize=false)注释引起了,加上该注释后,重新启动服务打开CP模块,一切正常。