朋友讲他在做struts2 + spring3 + hibernate3 的例子时出现了问题,其它的访问都正常但就是返回时异常:
No result defined for action cn.user.action.UserAction and result success
就向我求救,正好我对struts2有兴趣,就也拿过来学习了一下。
配置文件:
UserAction.java
<package name="ttt" namespace="/test" extends="struts-default">
<action name="list" class="userAction" method="execute">
<result name="success">/WEB-INF/page/user.jsp</result>
</action>
<action name="x_list" class="userAction" method="x_execute">
<result name="success">/WEB-INF/page/user.jsp</result>
</action>
</package>
访问路径: IP:端口/项目/test/list IP:端口/项目/test/x_list; 没问题。
但是很奇怪是的 IP:端口/项目/user竟然也能访问到action中。 但是返回时就出现了
No result defined for action cn.user.action.UserAction and result success 错误。
经过多方查找资料发现,struts2中有一个struts2-convention-plugin-2.1.8.1.jar包,这个包是一个插件。
作用是根据配置(默认)自动加载项目中使用action,actions,struts,struts2包下的类,将有execute方法的类映射成action. UserAction 映射成了 user;
所以通过 IP:端口/项目/user 访问的话返回就出现找不到路径的错误了。
解决办法:
不是用自动加载的:在struts.xml加入
<constant name="struts.convention.package.locators.disable" value="true"/>
使用自动加载的:
在convention中有以下配置
<constant name="struts.convention.result.path" value="/WEB-INF/content/"/>
所以根据配置在/WEB-INF/content/ 创建jsp了。文件名为:actionName-resultString
本例的JSP的文件名为:user-success.jsp。
访问路径告一段落,但是新的问题有出现鸟.。
通过convention自动注入的service在spring中必须找的到;
例:userAction 中有属性 userService;那么在spring中必须有配置:
<bean id="userService" class="xxx"></bean>
所以通过接口就不能正常的注入哦。
搞了半天多不想在墨迹了先记录一下。
分享到:
相关推荐
jsp\No result defined for action and result input.doc
No result defined for action.doc
最近在使用python过重遇到这个问题,NameError: name 'xxx' is not defined,在学习python或者在使用python的过程中这个问题大家肯定都遇到过,在这里我就这个问题总结以下几种情况: 错误NameError: name ‘xxx’ ...
3G软件无线电software defined radio for 3G,很不错,可惜是英文的,
linux ls find 时大于2G文件时出现Value too large for defined data type 系统本身支持大于2G文件但查询有问题的解决办法
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-...
Learn to:Control storage costs,Eliminate storage bottlenecks,Use IBM GPFS to solve storage management challenges
to present signal processing principles used in the software defined radio, ranging from analog ,digital modulation to RF, DSP and data conversion.
今天小编就为大家分享一篇解决Pycharm下面出现No R interpreter defined的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
主要介绍了webpack DllPlugin xxx is not defined解决办法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Multi-Band Software Defined Radio for Spaceborne Communications, Navigation, Radio Science, and Sensors
django执行命令 python manage.py startapp xxx报错os not defined问题
Understanding the Need for SD‐WAN....................................... 7 Dealing with applications hindered by expensive bandwidth......................................................................
中文译名《软件无线电中的射频与数字信号处理》,不可多得的一部实用的软件无线电著作,可以当作手册,供工程人员参考借鉴。
SteganoImage 1.0 绿色版
You have not defined a root partition which is required for installation of Rocks to continue You have not created a boot efi partition This can happen if there is not enough space on your hard ...
Zabbix 新版微信告警配置攻略,肯定是你需要的,有故障即时通知
vi编辑器是Linux和Unix上最基本的文本编辑器,工作在字符模式下。由于不需要图形界面,vi是效率很高的文本编辑器。尽管在Linux上也有很多图形界面的编辑器可用,但vi在系统和服务器管理中的功能是那些图形编辑器所...