在学strust,做一个简单的登录页面出错:No action instance for path /login could be created,不知如何是好,请大家指点一下,谢谢!web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <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>
    <init-param>
      <param-name>debug</param-name>
      <param-value>3</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>3</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</web-app>struts-config.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
  <data-sources />
  <form-beans />
  <global-exceptions />
  <global-forwards />    
  <action-mappings>
    <action
      path="/login"
      scope="request"
      type="com.test.struts.action.login">
      <forward
        name="success"
        path="/index.jsp" />
    </action>  
  </action-mappings>
  <message-resources parameter="com.handcall.struts.ApplicationResources" />
</struts-config>
login.jsp...
<form name="login" action="login.do" method="post">
用户名:&nbsp;<input name="login" type="text">
密码:&nbsp;<input name="pass" type="password">
<input type="submit" value="登录">
</form>
...login.class路径:WEB-INF\classes\com\test\struts\action\login.class

解决方案 »

  1.   

    你的struts-config.xml配置错了好像,<action-mappings>
        <action
          path="/login"
          scope="request"
          type="com.test.struts.action.login">
          <forward
            name="success"
            path="/index.jsp" />
        </action>  
    这个当中怎么没有attribute的值啊,这个值是actionform的,你怎么没有写啊!
    还有你的<form-bean>呢
      

  2.   

    ………… LZ你帖出来的程序还有别的错误 没有细看  但ACTION那里的配制肯定做了 
    1、没有配制对应的FORMBEAN
    2、TYPE属性配错了。里面应该是那个ACTION的完整名称(包括包名)用这个试试  看还报错不 ?
     <action-mappings>
        <action
          path="/login"
          name="loginForm"
          scope="request"
          type="com.login.struts.action.LoginAction">
        </action>  
      </action-mappings>
      

  3.   

    package com.test.struts.action;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;public class login extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) { if (request.getParameter("login") == "") {
    request.setAttribute("message", "<script>alert('请输入您的帐号!');</script>");
    return mapping.findForward("IndexPage");
    }
    if (request.getParameter("pass") == "") {
    this.mErr = "请输入您的密码!";
    request.setAttribute("message", "<script>alert('请输入您的密码!');</script>");
    return mapping.findForward("IndexPage");
    } return mapping.findForward("success");
    }}
      

  4.   

    上面是我的login.java代码,大家帮帮我吧,我实在是找不到哪里出错?!
      

  5.   

    <form name="login" action="login.do" method="post">
    改为
    <form name="/login.do" action="login.do" method="post">
    另外if (request.getParameter("login") == "") {
    .....
    这样写是不对的,要
    if ("".equals(request.getParameter("login"))) {
      

  6.   

    <form name="login" action="login.do" method="post">
    改为
    <form name="login" action="/login.do" method="post">
    这样
      

  7.   

    to:zhh1981(**的猪头)
    改成:action="/login.do"后出现错误:The requested resource (/login.do) is not available. 怎么办?
      

  8.   

    改成这样action="<%=request.getContextPath()%>/login.do"
      

  9.   

    to: tcmis(难道你忘了吗?) 、zhh1981(**的猪头)
    改成:action="<%=request.getContextPath()%>/login.do"后出现错误:No action instance for path /login could be created. 又回到问题的开始,怎么办?
      

  10.   

    把ACTION类的名字第一个改大写看看
      

  11.   

    to:zhh1981(**的猪头) 
    真的可以了,郁闷呀,把ACTION类的名字第一个改成大写就行了!这是怎么回事呀?!
      

  12.   

    JAVA规定类名第一个字母要大写,虽然小写有时候也可以,但是还是遵循规范好了
      

  13.   

    谢谢大家,特别感谢zhh1981(**的猪头)!