There is no Action mapped for namespace / and action name UserAction

果断收藏了,说的非常具体。刚開始学习的人常常遇到的问题。

There is no Action mapped for namespace / and action name UserAction

在网上找了好久才找解到的方法,事实上是由于我的struts.xml文件放错了位置,server没有载入上导制。

之后将struts.xml文件移到src文件夹下就能够了。

将自己在网上的搜到的解决方式贴在这里供网友们以后解决这个问题的时候參考。

可能的原因:
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方法的代码


来源:http://www.verydemo.com/demo_c140_i44529.html

原文地址:https://www.cnblogs.com/zfyouxi/p/4270727.html