我試用了互聯網上提供的所有可能的解決方案。Struts 2 - 沒有爲命名空間[/]和與上下文路徑[/ LoginApplication]關聯的操作名稱[validateLogin]映射的操作
錯誤:
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>
的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>
您使用的是什麼版本的S2?你嘗試過「/validateLogin.action」嗎?任何你不使用S2標籤的原因?另外,您應該將您的JSP頁面放在WEB-INF下,以防止直接訪問客戶端。因爲它是默認的,所以不需要指定「執行」方法。 –
將您的項目置於開發模式併發布我們分析問題的日誌。 http://struts.apache.org/2.3.4.1/docs/devmode.html –
我使用的是struts-2.3.4.1。我是struts新手。 – piresashwin