There is no result type defined for type 'json'...

struts2的json plugin可以实现struts2和json的完美结合,struts2的官方文档:http://struts.apache.org/2.2.1.1/docs/json-plugin.html

刚刚整合struts2和json出现了个小问题There is no result type defined for type 'json',

在struts.xml中有如下action定义

<action name="menu" class="com.lsw.permission.action.MenuAction"
	method="getFunctionMenu">
	<result name="success" type="json">
		<param name="root">json</param>
	</result>
</action>


在上面的定义中,action的result的type为json,json plugin就可将action中定义为groupList的field自动转换为json格式数据,并返回给前端UI。

但在deploy后,启动tomcat时却报了There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'?的错误,因为struts2找不到json这个result type的定义。解决方法有下面两种:

1.将当前package的extends属性改为"json-default",即让当前package从josn-default继承而不是struts-default继承;

2.但如果当前package确实无法继承"json-default"的话,还可以在当前package中定义result-type,将json给加进去,如下:

<result-types><!-- 定义json类型 -->
	<result-type name="json" class="org.apache.struts2.json.JSONResult" />
</result-types>


转载于:https://my.oschina.net/lsw90/blog/63211

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值