刚学的struts,总是出现404的错误,搞了几个小时都没有找到错误,我看的是王勇的struts视频,刚开始以为是配置文件写错了,但是我把原版的配置文件拷贝过来,还是这个错误啊!struts-config.xml<?xml version="1.0" encoding="ISO-8859-1" ?><!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="calForm" type="struts.CalActionForm"></form-bean>
</form-beans><action-mappings>
  <action path="/cal"
          type="struts.CalAction"
          name="calForm"
          scope="request"
  >
  <forward name="success" path="/success.jsp" />
  <forward name="error" path="/error.jsp"  />
  </action>
</action-mappings>
</struts-config>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>

解决方案 »

  1.   

    没有找到页面,debug一下你的mapping.forward的路径是否指定到jsp页面,
      

  2.   

    /success.jsp
    检查是这个路径么?
      

  3.   

    encoding="ISO-8859-1"
    改为
    encoding="UTF-8"检查action 里面是不是:
    return mapping.findForward("success");

    return mapping.findForward("error");另外你的页面action写对没?是不是按配置里面方的文件?
      

  4.   

    不能完全按照视频来整的
    http://www.blogjava.net/max/archive/2006/10/10/74353.html
      

  5.   

    JSP页面form的action有没有写对!!!
      

  6.   

    <action path="/cal" 
              type="struts.CalAction" 
              name="calForm" 
              scope="request" 
      > 
    估计是这段配置与前面的CalAction类不协调
    你的CalAction类是继承MappingDispatchAction 还是继承Action
    若是前者那这段配置是<action path="/cal"
               parameter="你在CalAction类中的方法名" 
              type="struts.CalAction" 
              name="calForm" 
              scope="request" 
      > 
    若是后者,即继承Action
    配置是<action path="/CalAction" type="struts.CalAction"
           name="calForm" 
            scope="request"
           >