Struts2 Struts 2-与上下文路径[/LoginApplication]关联的命名空间[/]和操作名称[validateLogin]没有映射的操作
我在互联网上尝试了所有可能的解决方案 错误:Struts2 Struts 2-与上下文路径[/LoginApplication]关联的命名空间[/]和操作名称[validateLogin]没有映射的操作,struts2,struts2-namespace,action-mapping,Struts2,Struts2 Namespace,Action Mapping,我在互联网上尝试了所有可能的解决方案 错误: HTTP Status 404 - There is no Action mapped for namespace [/] and action name [validateLogin] associated with context path [/LoginApplication]. struts.xml文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBL
HTTP Status 404 - There is no Action mapped for namespace [/] and action name [validateLogin] associated with context path [/LoginApplication].
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>
<constant name="struts.devMode" value="true" />
<package name="hello" extends="struts-default">
<action name="validateLogin"
class="com.example.login.ValidationAction"
method="execute">
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
/result.jsp
index.jsp
<form action="validateLogin">
<table>
<tr>
<td><label for="username">Username</label></td><td><input type="text" name="username"></td>
</tr>
<tr>
<td><label for="password">Password</label></td><td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Login"></td>
</tr>
</table>
</form>
用户名
密码
我的问题的解决方案有点奇怪
我刚刚从struts.xml文件中删除了
程序开始正常运行。。。然后我又将相同的代码放回struts.xml文件中,它仍在运行。…此错误主要发生在包结构不正确时
如果web.xml
文件和struts.xml
文件是在正确的包下创建的,那么这两个xml文件将自动反映在Netbeans中的Configuration files文件夹结构下
请参阅:确保struts.xml
位于正确的目录中。
如果您使用的是Eclipse,则可以执行以下步骤:
1-右键单击项目⇾ 性质⇾ 部署程序集
2-使源的部署路径如下所示:
-/Src/main/java:WEB-INF/classes
-Struts2(库):WEB-INF/lib
3-将struts.xml
放在部署路径为EWEB-INF/classes
的目录中。
例如,这里您应该将它放在/src/main/java
您使用的是什么版本的S2?你试过“/validateLogin.action”吗?你为什么不使用S2标签?此外,您可能应该将JSP页面置于WEB-INF下,以防止客户端直接访问。无需指定“execute”方法,因为它是默认方法。将您的项目置于开发模式,然后发布日志,我们将分析问题。我正在使用struts-2.3.4.1。我是struts新手。我使用了开发者模式。。。I’我一点也没有logs@piresashwin/WEB-INF/result.jsp。顺便说一句,您不需要编写name=“success”
,因为这也是默认值。不,这根本不是根本原因。