我正在尝试在Eclipse中使用Maven构建Struts 1 Web项目。我收到以下错误:


我的pom.xml如下:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.practice</groupId>
  <artifactId>maven-practice</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>maven-practice Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-core</artifactId>
      <version>1.3.10</version>
    </dependency>
     <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-taglib</artifactId>
      <version>1.3.10</version>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-el</artifactId>
      <version>1.3.10</version>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-tiles</artifactId>
      <version>1.3.10</version>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-faces</artifactId>
      <version>1.3.10</version>
    </dependency>
    <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts-scripting</artifactId>
      <version>1.3.10</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>maven-practice</finalName>
  </build>
</project>


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>
    <form-beans>
          <form-bean name="HelloWorldForm" type="vanila.HelloWorldForm" />
          <form-bean name="SignUpForm" type="vanila.SignUpForm" />
    </form-beans>

    <global-exceptions>

    </global-exceptions>

    <global-forwards>
        <forward name="welcome" path="/Welcome.do" />
    </global-forwards>

    <action-mappings>

        <action name="HelloWorldForm" path="/HelloWorld" type="vanila.HelloWorldAction" validate="true" input="/home/index.jsp" scope="request">
            <forward name="success" path="/home/helloWorld.jsp" />
            <forward name="error"   path="/home/error.jsp" />
            <forward name="signup"   path="/home/signUp.jsp" />
        </action>

        <action name="SignUpForm" path="/SignUp" type="vanila.SignUpAction" validate="true" input="/home/signUp.jsp" scope="request">
            <forward name="success" path="/home/success.jsp" />
            <forward name="error"   path="/home/error.jsp" />
        </action>

    </action-mappings>

    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />

    <message-resources parameter="com/vaannila/ApplicationResource" />


    <plug-in className="org.apache.struts.tiles.TilesPlugin">
        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
        <set-property property="moduleAware" value="true" />
    </plug-in>

    <!-- ========================= Validator plugin ================================= -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
    </plug-in>

</struts-config>


最后是web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>

<!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>
<display-name>
    maven-struts-practice</display-name>
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>application</param-name>
      <param-value>livechat</param-value>
    </init-param>
    <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>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
        <param-name>listings</param-name>
        <param-value>false</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>
    <session-config>
    <session-timeout>60</session-timeout>
  </session-config>


    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>


  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
  </taglib>


</web-app>


更具体地说,这是我的项目结构:



帮我解决这个问题。

最佳答案

检查WEB-INF中tld文件的版本以及库中相应的jar文件。

我在lib文件夹中有struts-tiles-1.3.10.jar,在WEB-INF中有旧版本的struts-tiles.tld。它引发了我同样的错误。用我替换的struts-tiles.tld文件进入WEB-INF文件夹中的struts-tiles-1.3.10.jar(通过提取jar文件)后,它工作正常。

关于java - 无法加载或实例化TagExtraInfo类:org.apache.struts.taglib.bean.CookieTei,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25424814/

10-15 10:23