struts2的json plugin可以实现struts2和json的完美结合,由于本篇主要是介绍整合过程中遇到的问题,所以编程实现的方法这里就不重复了,具体可以参看struts2的官方文档:http://struts.apache.org/2.2.1.1/docs/json-plugin.html。
我在struts.xml中有如下action定义:
<action name="product_group" class="customers.products" method="getGroups">
<result type="json">
<param name="root">groupList</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>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
两种方法的原理:
json这个result type是在json-default (struts2-json-plugin-2.1.8.1.jar\struts-plugin.xml)里面定义的,内容如下(省去了xml和doctype标签):
<struts>
<package name="json-default" extends="struts-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
<interceptors>
<interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/>
</interceptors>
</package>
</struts>
可见,name为"json"的result type是在json-default中定义的,所以,从json-default继承就可以使用json这个result。另外json-default还定义了一个name为"json"的interceptor。
另外,依json-default的定义来看,方法2中还应该再加一个json的interceptor定义才比较合适。
相关推荐
jsp\No result defined for action and result input.doc
No result defined for action.doc
linux ls find 时大于2G文件时出现Value too large for defined data type 系统本身支持大于2G文件但查询有问题的解决办法
以上这篇解决Pycharm下面出现No R interpreter defined的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持软件开发网。 您可能感兴趣的文章:pycharm 使用心得(九)解决No Python ...
json11 is a tiny JSON library for C++11, providing JSON parsing and serialization. The core object provided by the library is json11::Json. A Json object represents any JSON value: null, bool, number...
但是在项目经过本地测试没有任何问题,打包上线后却会报错 webpackJsonp is not defined。这是因为公共文件必须在自己引用的js文件之前引用。 可以手动改文件引用,但是推荐以下解决办法: 找到build→webpack.prod...
C++经典错误之already defined in *****.obj解决方法
3G软件无线电software defined radio for 3G,很不错,可惜是英文的,
RF and Digital Signal Processing for Software-Defined Radio: A Multi-Standard Multi-Mode Approach by Tony J. Rouphael RF and Digital Signal Processing for Software-Defined Radio: A Multi-...
使用json2typescript ,仅需要一个简单的函数调用,如下面的TypeScript代码片段所示: // Assume that you have a class named User defined at some point// Assume that you get a JSON string from a ...
网上的东西好大多都不能直接用,自己结合网上资料做了一个Struts2+Spring3+MyBatis3的测试工程,JUnit测试用例和WEB服务。 内涵完整jar包,解压直接可用,包括一个表文件。 Eclipse3.2+Tomcat/5.5+jdk1.5.0_17 - ...
Learn to:Control storage costs,Eliminate storage bottlenecks,Use IBM GPFS to solve storage management challenges
*方法 */ DragZoomControl.prototype.saveMapContext = function(text) { if (this.globals.options.backButtonEnabled) { this.saveBackContext_(text,true); this.globals.backButtonDiv.style....
to present signal processing principles used in the software defined radio, ranging from analog ,digital modulation to RF, DSP and data conversion.
struts1.3.9 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the ...
java-struts2.2的驱动包 2009-8-29 14:02:04 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache Tomcat Native library which allows optimal performance in production ...
. eclipse 4.1 导入项目后 Target runtime Apache Tomcat v6.0 is not defined
and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal ...
json-schema-viewer JSON模式查看器React组件探索组件:查看更改日志:产品特点全面的JSON Schema Draft 4支持,包括oneOf和anyOf组合器属性将复杂的嵌套对象渲染到任何深度渲染验证属性和降价描述能够链接已解决的$...