日期:2014-05-20  浏览次数:20632 次

struts2问题-There is no Action mapped for namespace
这个是我的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>/result.jsp</result>
</action>
</package>
</struts>
这个是我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  
  <filter>
  <filter-name>struts2</filter-name>
  <filter-class>
  org.apache.struts2.dispatcher.FilterDispatcher
  </filter-class>
  </filter>
  
  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
</web-app>
这是是我的bean文件
package com.test.action;

public class LoginAction {
private String username;
private String password;

public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public String execute() throws Exception{
return "success";
}
}
这个是jsp文件:
<body>
  <form action="login.action" method="post">
  username:<input type="text" name="username">
  password:<input type="password" name="password">
 
  <input type="submit" value="submit">
  </form>
  
  </body>
当我点submit时:报了这样一个错HTTP Status 404 - There is no Action mapped for namespace / and action name login,不知道是怎么回事。在网上查了好多,但是没有一个能解决的。希望高手来帮忙一下。

------解决方案--------------------
你的struts怎么配置的.还有这个web.xml如何找到你的struts.xml文件

我是完全看不懂,也许我太菜了!