JSONException:java.lang.reflect.InvocationTargetException异常处理

由于我使用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模块,一切正常。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值