tomcat启动时好像没有装入action和formbean,请问这是为什么?

解决方案 »

  1.   

    你的web.xml和struts-config.xml没有配置正确吧
    具体的要看你的源文件了嘻嘻
      

  2.   

    web.xml文件:<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"><web-app>
      <!-- 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>
        <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>2</load-on-startup>
      </servlet>
      <!-- Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <!-- The Welcome File List -->
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list></web-app>
      

  3.   

    struts_config.xml文件:<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
              "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"><!--
         This is the Struts configuration file for the example application,
         using the proposed new syntax.     NOTE:  You would only flesh out the details in the "form-bean"
         declarations if you had a generator tool that used them to create
         the corresponding Java classes for you.  Otherwise, you would
         need only the "form-bean" element itself, with the corresponding
         "name" and "type" attributes.
    -->
    <struts-config>
      <!-- ========== Data Source Configuration =============================== -->
    <!--
     <data-sources>
       <data-source>
         <set-property property="autoCommit"
                          value="false"/>
         <set-property property="description"
                          value="Example Data Source Configuration"/>
         <set-property property="driverClass"
                          value="org.postgresql.Driver"/>
         <set-property property="maxCount"
                          value="4"/>
         <set-property property="minCount"
                          value="2"/>
         <set-property property="password"
                          value="mypassword"/>
         <set-property property="url"
                          value="jdbc:postgresql://localhost/mydatabase"/>
         <set-property property="user"
                          value="myusername"/>
       </data-source>
     </data-sources>
    -->
      <!-- ========== Form Bean Definitions =================================== -->
      <form-beans>    <!-- Logon form bean -->
    <!--
        <form-bean      name="logonForm"
                        type="org.apache.struts.webapp.example.LogonForm"/>
    -->
    <!--
        <form-bean      name="logonForm"
                        type="org.apache.struts.action.DynaActionForm">
    -->
        <form-bean      name="albumLogonForm"
                        type="com.dmgc.unicom.web.personalbum.AlbumLogonForm">
          <form-property name="userName" type="java.lang.String"/>
          <form-property name="password" type="java.lang.String"/>
        </form-bean>
        <form-bean      name="configAlbumForm"
                        type="com.dmgc.unicom.web.personalbum.ConfigAlbumForm">
        <form-property name="albumName" type="java.lang.String"/>
           <form-property name="sharedLevel" type="java.lang.String"/>
           <form-property name="selectedAlbumID" type="int" />
        </form-bean>  <form-bean      name="addAlbumForm"
                        type="com.dmgc.unicom.web.personalbum.AddAlbumForm">
          <form-property name="albumName" type="java.lang.String"/>
          <form-property name="sharedLevel" type="java.lang.String"/>
      </form-bean>  <form-bean      name="DeleteAlbumForm"
                        type="com.dmgc.unicom.web.personalbum.DeleteAlbumForm">
          <form-property name="selectedAlbumID"  type="int"/>
      </form-bean>
      <form-bean      name="DeletePhotoForm"
                       type="com.dmgc.unicom.web.personalbum.DeletePhotoForm">
          <form-property name="selectedAlbumID"  type="int"/>
        <form-property name="photoID" type="int" />
      </form-bean>
    <!--
    <form-bean      name="UploadPhotoForm"
                        type="com.dmgc.unicom.web.personalbum.UploadPhotoForm">
          <form-property name="selectedAlbumID" />
          <form-property name="photoName" type="java.lang.String" />
          <form-property name="photoFile" type="java.lang.String" />
      </form-bean>
      -->
    </form-beans>
      <!-- ========== Global Forward Definitions ============================== --> <global-forwards>
        <forward   name="albumlogonsucess"               path="/Person_Photo/browse.jsp"/>
        <forward   name="albumlogonfailure"                path="/Person_Photo/index.jsp"/>
      </global-forwards>  <!-- ========== Action Mapping Definitions ============================== -->
      <action-mappings>    <!-- Edit user registration -->
        <action    path="/Person_Photo/AlbumLogon"
                   type="com.dmgc.unicom.web.personalbum.AlbumLogonAction"
                   name="albumLogonForm"
                   scope="request"
                   input="/Person_Photo/index.jsp"
               validate="false">
        </action>
    <action    path="/Person_Photo/AddAlbum"
                   type="com.dmgc.unicom.web.personalbum.AddAlbumAction"
                   name="addAlbumForm"
                   scope="request"
                   input="/Person_Photo/addalbum.jsp"
               validate="true">
        </action>    <action    path="/Person_Photo/ConfigAlbum"
                   type="com.dmgc.unicom.web.personalbum.ConfigAlbumAction"
                   name="configAlbumForm"
                   scope="request"
                   input="/Person_Photo/configalbum.jsp"
               validate="true">
        </action>   <action    path="/Person_Photo/DeleteAlbum"
                   type="com.dmgc.unicom.web.personalbum.DeleteAlbumAction"
                   name="DeleteAlbumForm"
                   scope="request"
                   input="/Person_Photo/deletealbum.jsp"
               validate="true">
      </action>
        <action    path="/Person_Photo/DeletePhoto"
                   type="com.dmgc.unicom.web.personalbum.DeletePhoto"
                   name="DeletePhotoForm"
                   scope="request">
      </action>
    <!--
    <action    path="/Person_Photo/UploadPhoto"
                   type="com.dmgc.unicom.web.personalbum.UploadPhotoAction"
                   name="UploadPhotoForm"
                   scope="request"
                   input="/Person_Photo/upload_photo.jsp"
               validate="true">
      </action>
    -->
    </action-mappings>  <!-- ========== Controller Configuration ================================ -->
    <!--
      <controller>
        The "input" parameter on "action" elements is the name of a
             local or global "forward" rather than a subapp-relative path
        <set-property property="inputForward" value="true"/>
      </controller>
    -->
      <!-- ========== Message Resources Definitions =========================== -->  <message-resources
        parameter="com.dmgc.unicom.ApplicationResources"/>
      <!-- ========== Plug Ins Configuration ================================== -->  </struts-config>
      

  4.   

    建议搂主先对Structs有一个更深的认识。
      

  5.   

    to  muskteeeer(跳蚤):身不由己啊,现在是赶鸭子上架,拜托老兄指点一二!
      

  6.   

    异常:Cannot find ActionMappings or ActionFormBeans collection中collection是什么意思,应该是我自己定义的actions和formbeans吧,现在找不到可能有两个原因:
    1、程序中引用错误,引用这些actions和formbeans时名称写错了,目前这个原因可以排除,因为我做过检查,而且原来这段程序运行正常,后来也没有做任何改动就不能运行了;
    2、tomcat没有装入struts_config.xml文件中的配置信息,这个原因很有可能,因为在tomcat启动时并没有显示装入这些类的信息。
    如果是问题2造成的,请问该如何解决。
      

  7.   

    看了楼主的分析,我觉的第二中可能性比较大,
    下面的连接可以给你帮助
    http://expert.csdn.net/Expert/topic/1121/1121100.xml?temp=.61607
      

  8.   

    如果所有的form都不能用肯定是2,
    否则,建议检查配置文件,注意 /
      

  9.   

    问题已经解决了,原来WEB-INF/lib下面少了几个与struts.jar关联的包,所以tomcat启动时没有把struts包装入,造成这个问题。
    多谢各位,请帮我看看这个更头疼的问题:
    http://expert.csdn.net/Expert/topic/1781/1781883.xml?temp=.218136