No action config found for the specified url.是struts-config.xml的配置问题,但是仔细改了几遍,也问了老师,始终无法解决。
1,struts-config的配置文件
 
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://struts.apache.org/dtds/struts-config_1_3.dtd"><struts-config>
<form-beans>
<form-bean name="loginForm" type="com.mayn.actionForm.LoginActionForm"/>
</form-beans>

<action-mappings>
<action path="/login"
type="com.mayn.action.LoginAction"
name="loginForm"
scope="request">
<forward name="success" path="/information/success.jsp"/>
<forward name="failure" path="/information/error.jsp"/>
</action>
</action-mappings>
</struts-config>

2,web.xml的配置文件

<?xml version="1.0" encoding="ISO-8859-1"?>  <!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"><web-app>
  <display-name>Struts Blank Application</display-name>
  
  <!-- Standard Action Servlet Configuration -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
 </servlet>
 
  <!-- Standard Action Servlet Mapping -->
  
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
  
  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list></web-app>3,login.jsp<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Login Page</title>
</head>
<body>
<h1>User Login</h1>
<hr>
<form action="login.do" method="post">
Username: <input type="text" name="username"><br/>
Password: <input type="password" name="password"><br>
<input type="submit" value="Login">
<input type="reset" value="Reset"><br/>
</form>
</body>
</html>4,LoginAction.javapackage com.mayn.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.mayn.actionform.LoginActionForm;
import com.mayn.exception.PasswordErrorException;
import com.mayn.exception.UserNotFoundException;
import com.mayn.manager.UserManager;public class LoginAction extends Action 
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception
{
LoginActionForm loginActionForm = (LoginActionForm)form;
String username = loginActionForm.getUsername();
String password = loginActionForm.getPassword();

// if("mayn".equals(username) && "mayn".equals(password))
// {
// System.out.println("Has Logged");
// request.setAttribute("username", username);
// return mapping.findForward("success");
// }
// else
// {
// System.out.println("Logged was failured!");
// return mapping.findForward("failure");
// }
String errorInfo = null;
try
{
UserManager.getInstance().validate(username, password);
request.setAttribute("username", username);
return mapping.findForward("success");
}catch (UserNotFoundException unfe)
{
unfe.printStackTrace();
errorInfo = "Your username [" + username +"] is error!";
}
catch (PasswordErrorException pee)
{
pee.printStackTrace();
errorInfo = "Your password is error!";
}

request.setAttribute("errorInfo", errorInfo);
return mapping.findForward("failure");
}
}5,另有LoginActionForm.java在com.mayn.actionform包中,success.jsp和error.jsp也面在WEB-INF/information/路径下。

解决方案 »

  1.   

    仔细的检查你的struts的配置文件,action的路径看看写错没有,这种问题应该不是技术的
      

  2.   

    1.先看看服务器启动时,用什么报错没
    2.login.jsp页应该直接放到web跟目录下,否则提交时url不正确
    正确的url应该为:项目名/login.do
    3.你的<forward name="success" path="/information/success.jsp"/>
    配置有误,success.jsp页应该放在根目录下的information目录下而不是在WEB-INF/information/
    但这不是造成你出错的原因。