struts2关于"There is no Action mapped for namespace / and action name"的解决方法

来源:互联网 发布:关键词外包优化 编辑:程序博客网 时间:2024/04/28 23:33

初次配置struts2,出现了"There is no Action mapped for namespace / and action name"的问题,网上搜索解决方案一大堆,但是我的依然不行,最后才发现了问题。

首先说一下其他可能出现的问题:

1.struts.xml的位置不对,应该放在src下面。

2.struts.xml里面的参数配置不对,这个问题可能是大家比较常见的吧,对照着Struts示例模板好好看下自己写的,应该能发现问题。

3.初学者因为不明白,手误导致的错误,这也是我犯的错误。url里面我提交后的地址是helloWorld.action,但是在struts.xml配置里面,action name属性的值却成了helloworld

因为Struts是通过名字去过滤的,所以导致不成功,一直报错。

提出部分关键代码:

jsp页面中

<a href="${pageContext.request.contextPath}/helloWorld.action">helloworld</a>

Struts.xml配置中

<action name="helloworld" class="cn.action.HelloWorld">
          <result name="success">/welcome.jsp</result>
    </action>

0 0