"There is no Action mapped for namespace / and action name XXX" 估计是struts2入门都会遇到的问题
简单的总结一下今天的问题:
1.把struts.xml文件放在了WEB-INF文件夹里了,这是Struts1.x的思维定势,尽管资料上明确地指明要放在WEB-INF/classes文件里(也就是myeclipse的src文件下)
2.namespace属性的设置问题:这个属性在pakage和<s:form>中都有,如果是在struts.xml文件中的pakage的属性namespace上设置了,那么在写<s:form>的action时就要写成:namespace的属性+action或者namespace的属性/../action的名称(不需加后缀),介于namespace和action名之间可以有其他路径。举个例子:若你的struts.xml的文件如下配置,请留意namespace属性
<?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" namespace="/check" extends="struts-default">
<action name="login" class="com.cetus.web.struts.LoginAction" >
<result name="failure">/erro.jsp</result>
<result name="success">/index.jsp</result>
</action>
</package>
然后是登陆界面的<s:form>
<s:form action="/check/login" method="POST" >
<s:textfield name="username" label="用户名"></s:textfield>
<s:textfield name="pwd" label="密码"></s:textfield>
<s:submit value="登录"></s:submit>
</s:form>
<s:form>的namespace属性可写可不写,试了试乱写都没报错呢....因为配置了pakage的namespace的属性,<s:form>的action就可以配置为:action="check/login"或者action="check/a/login"等,struts在寻找action时会在namespace下的文件夹逐个找 直到找到为止。
综上所述:注意namespace的用法,不配置的话,action的路径怎么写都可以,但最后的斜干后必须是动作名,如果配置了的话<s:form>的action属性就必须是namespace属性+中间可以加多级的路径也可以不加+动作名.
分享到:
相关推荐
logging-1.1.1.jar/ezmorph-1.0.6.jar/freemarker-2.3.22.jar/javassist-3.11.0.GA.jar/json-lib-2.4-jdk15.jar/log4j-api-2.2.jar/log4j-core-2.2.jar/ognl-3.0.6.jar/struts2-core-2.3.24.jar/xwork-core-2.3.24....
<package name="erpweb" extends="struts-default"> <result name="IOException" >/error/ioexception.jsp</result> <result name="SQLException" >/error/sqlexception.jsp</result> </global-results> ...
NULL 博文链接:https://cdxs2.iteye.com/blog/1925245
Spring In Action && Hibernate In Action && Struts2 In Action 共三份pdf文档
structs2拦截器实例计算action执行的时间,涉及拦截器,structs.xml的配置等等。。
1.2 Main characteristics, context and reasons for developing a new language....................4 1.2.1 Languages that influenced Go.......................................................................
1.2 Main characteristics, context and reasons for developing a new language....................4 1.2.1 Languages that influenced Go.......................................................................
The main reason for making a virtual function inline is to place its definition in the class, either for convenience or to document its behavior, e.g., for accessors and mutators. The -inl.h Files...
如题,eclipse工程,项目框架已搭好,ext包与引用jar包由于限制无法上传。
8. …//getter and setter 9. } 特别需要注意的是:数据库表为Blob类型的字段在Tfile中的fileContent类型为byte[]。Tfile的Hibernate映射文件Tfile.hbm.xml放在Tfile .java类文件的相同目录下: 代码 2 领域...
structs in action中文完全版\6. 连线 ActionForward.pdf
构建structs2所需的基本jar包
ejb3_structs ejb and jboss
Java Web Structs2开发
Code Visualizer is very easy to use and includes powerful C/C++ analysis engine and intuitive drawing engine. Code Visualizer really saves your precious time. Features: • Analysis C/C++ files and ...
NULL 博文链接:https://ihuning.iteye.com/blog/2233463
3.4 Name lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3.5 Program and linkage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
structs in action中文完全版\9. 扩展 ActionServlet.pdf
int tgt=spiRamFifoLen()/2; ret=(spiRamFifoFill()-tgt)*ADD_DEL_BUFFPERSAMP; } return ret; } //This routine is called by the NXP modifications of libmad. It passes us (for the mono synth) //32 ...
jsp自定义标签 structs2 JUNIT structs2自定义拦截器