读Struts2深入详解第六章代码调试问题There is no Action mapped for namespace [/] and action name [register!default]
来源:互联网 发布:linux计数统计文件命令 编辑:程序博客网 时间:2024/06/16 02:28
在学习孙鑫老师《Struts.2深入详解》时,按照步骤在不使用spring时,访问:“http://localhost:8080/ch06/register!default.action”时提示:
警告: Could not find action or result: /ch06/register!default.actionThere is no Action mapped for namespace [/] and action name [register!default] associated with context path [/ch06]. - [unknown location]at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Unknown Source)
在按网上的如下几种可能情况排查后问题仍然存在:
引用自:http://www.cnblogs.com/dshjava/articles/1435479.html
可能的原因:1.-----首先查看你的struts.xml 文件是否在src目录下;2.-----检查struts.xml文件的语法是否正确: 如果1正确的话那就一定是struts.xml文件的问题: <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="struts2" extends="struts-default"> <action name="login" class="com.test.action.LoginAction"> <result name="success">/result.jsp</result> </action></package></struts> 那么就只有是红字的部分写错了 查看你的是否吧struts-default中间的“-”错写成了struts=default;二.确定名称是 struts.xml三.粗心,仔细检查配置文件,和excute方法的代码
通过新增一个action直接调用doDefault方法后访问“http://localhost:8080/ch06/login.action”是可以成功的:
<action name="login" class="org.sunxin.struts2.action.RegisterAction" method="doDefault"> <!-- 配置异常映射,当RegisterAction抛出Exception异常时,向用户显示error.jsp页面 --> <exception-mapping result="error" exception="java.lang.Exception"/> <result name="input">/WEB-INF/pages/register.jsp</result> <result name="success">/WEB-INF/pages/success.jsp</result> <result name="error">/WEB-INF/pages/error.jsp</result> </action>
查了半天,才发现因为是Action的动态方法调用,所以又可能默认的struts没有开启这个配置项,在struts.xml增加这个配置项:
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>后调测OK:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package name="ch06" extends="struts-default"> <action name="register" class="org.sunxin.struts2.action.RegisterAction"> <!-- 配置异常映射,当RegisterAction抛出Exception异常时,向用户显示error.jsp页面 --> <exception-mapping result="error" exception="java.lang.Exception"/> <result name="input">/WEB-INF/pages/register.jsp</result> <result name="success">/WEB-INF/pages/success.jsp</result> <result name="error">/WEB-INF/pages/error.jsp</result> </action> <action name="login" class="org.sunxin.struts2.action.RegisterAction" method="doDefault"> <!-- 配置异常映射,当RegisterAction抛出Exception异常时,向用户显示error.jsp页面 --> <exception-mapping result="error" exception="java.lang.Exception"/> <result name="input">/WEB-INF/pages/register.jsp</result> <result name="success">/WEB-INF/pages/success.jsp</result> <result name="error">/WEB-INF/pages/error.jsp</result> </action> </package></struts>
struts2所有的constant常量可以在解压struts2-core-2.3.16.3.jar包后的struts2-core-2.3.16.3\org\apache\struts2\default.properties中查阅,又详细的说明
0 0
- 读Struts2深入详解第六章代码调试问题There is no Action mapped for namespace [/] and action name [register!default]
- J2EE Struts2关于"There is no Action mapped for namespace / and action name UserAction"的调试
- Struts2中关于"There is no Action mapped for namespace / and action name"的问题
- There is no Action mapped for namespace / and action name .
- There is no Action mapped for namespace / and action name
- There is no Action mapped for namespace / and action name
- There is no Action mapped for namespace / and action name
- There is no Action mapped for namespace [/] and action name
- There is no Action mapped for namespace / and action name .
- There is no Action mapped for namespace / and action name
- There is no Action mapped for namespace / and action name
- There is no Action mapped for namespace [/] and action name
- 彻底解决STRUTS2 错误There is no Action mapped for namespace / and action name login
- struts2之There is no Action mapped for namespace / and action name
- Struts2---There is no Action mapped for namespace / and action name
- struts2中There is no Action mapped for namespace / and action name ..
- struts2的异常There is no Action mapped for namespace / and action name --转
- Struts2 无法导向到首页There is no Action mapped for namespace / and action name
- HDOJ题目2660 Accepted Necklace(二维01背包)
- fut 14 coins Fa6F KleS cwOwi
- fifa coins R63p 5FJJ ImQNV
- ZipUtil
- PropertiesUtil
- 读Struts2深入详解第六章代码调试问题There is no Action mapped for namespace [/] and action name [register!default]
- 汉字转拼音工具类
- 2014湖南省大学生程序设计竞赛总结
- 数据库DQL语句
- iOS中为cagetory添加@property支持
- Qt SQL Programming 部分翻译
- 安卓下载功能中的广播接收器
- 如何利用SEO方式使网站增加流量
- 大数据已经悄悄来到我们身旁