应该是struts下的应用,检查一下web.xml中ActionMappings 和 ActionFormBeans 的设置

解决方案 »

  1.   

    是struts下的应用web.xml中ActionMappings 和 ActionFormBeans 是怎样设置的.web.xml的内容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>
      <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>2</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
      </taglib>
    </web-app>struts-config 的设置:<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
    <struts-config>
      <form-beans>
        <form-bean name="loginActionForm" type="struts.LoginActionForm" />
      </form-beans>
      <action-mappings>
        <action name="loginActionForm" type="struts.LoginAction" input="/Login.jsp" path="/loginAction" />
      </action-mappings>
    </struts-config>loginAction.java:
    package struts;import org.apache.struts.action.*;
    import javax.servlet.http.*;public class LoginAction extends Action {
      public ActionForward perform(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        /**@todo: complete the business logic here, this is just a skeleton.*/
        throw new java.lang.UnsupportedOperationException("Method perform() not yet implemented.");
      }
    }loginActionForm.java:
    package struts;import org.apache.struts.action.*;
    import javax.servlet.http.*;public class LoginActionForm extends ActionForm {
      private String name;
      public void setName(String name) {
        this.name = name;
      }
      public String getName() {
        return name;
      }
      public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
        /**@todo: finish this method, this is just the skeleton.*/
        return null;
      }
      public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
      }
    }
    login.jsp:
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>
    Login
    </title>
    </head>
    <body>
    <h1>JBuilder Generated Struts JSP for ActionForm struts.LoginActionForm</h1>
    <p>
    <html:form action="/loginAction.do" method="POST">
    <html:text property="name"/>
    <br>
    <html:submit property="submit" value="Submit"/><br>
    <html:reset value ="Reset"/>
    </html:form>
    </body>
    </html:html>