strutstileslistener在struts 2 tiles程序中找不到

时间:2013-10-17 19:01:34

标签: java struts2 tiles

我无法找到我的申请有什么问题。使用支柱2和瓷砖。 web.xml中:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>strutsForScoodle</display-name>

<context-param>
<param-name>
  org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</param-name>
<param-value>
  /WEB-INF/tiles.xml
</param-value>
</context-param>

<listener>
<listener-class>
  org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>

<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>

<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

Tiles.xml:

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

<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
<definition name="baseLayout" template="/WEB-INF/content/tiles/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/content/tiles/Header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/content/tiles/Footer.jsp" />
</definition>
<definition name="logoff.tiles" extends="baseLayout">
<put-attribute name="title" value="Logoff" />
<put-attribute name="body" value="/WEB-INF/content/tiles/logoff.jsp" />
</definition>
<definition name="createSurvey.tiles" extends="baseLayout">
<put-attribute name="title" value="create Survey" />
<put-attribute name="body" value="/WEB-INF/content/tiles/createSurvey.jsp" />
</definition>
</tiles-definitions>

struts.xml中:

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

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<package name="default" extends="struts-default">
  <result-types>
     <result-type name="tiles" 
     class="org.apache.struts2.views.tiles.TilesResult" />
  </result-types>

  <action name="*Navigate" method="{1}" 
     class="de.umfragetool.action.NavigateAction">
     <result name="overview" type="tiles">overview</result>
     <result name="logoff" type="tiles">logoff</result>
     <result name="createSurvey" type="tiles">createSurvey</result>
  </action>

  </package>
 </struts>

来自maven的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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Struts4Scoodle</groupId>
<artifactId>Struts4Scoodle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Scoodle</name>
<description>Scoodle Tool</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <source>1.7</source>
      <target>1.7</target>
    </configuration>
  </plugin>
  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <warSourceDirectory>WebContent</warSourceDirectory>
      <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>
 </plugins>
  </build>
 <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
                    <!--        struts -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.15.2</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.15.2</version>
</dependency>
<!--                            tiles -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.3.15.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-compat</artifactId>
<version>3.0.1</version>
</dependency>

</dependencies>
</project>

所有这些让我失败了:

  

`Okt 17,2013 8:34:41 PM org.apache.catalina.core.AprLifecycleListener   init信息:基于APR的Apache Tomcat Native库   没有找到生产环境中的最佳性能   java.library.path:C:\ Program   文件\的Java \ jre7 \ BIN; C:\ WINDOWS \太阳\的Java \ BIN; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ WINDOWS \ SYSTEM32 \ WBEM; C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0 \; C:\ PROGRAM   文件(x86)\ MiKTeX 2.9 \ miktex \ bin \; C:\ Program   文件\的Java \ jdk1.7.0_40; C:\ Apache的行家-3.1.1-BIN \ Apache的行家-3.1.1 \ BIN ;.   Okt 17,2013 8:34:41 PM   org.apache.tomcat.util.digester.SetPropertiesRule开始Warnung:   [SetPropertiesRule] {服务器/服务/引擎/主机/上下文}设置   属性'source'到'org.eclipse.jst.jee.server:Struts4Scoodle'做了   找不到匹配的属性。 Okt 17,2013 8:34:41 PM   org.apache.coyote.AbstractProtocolHandler init信息:   初始化ProtocolHandler [“http-bio-8080”] Okt 17,2013 8:34:41 PM   org.apache.coyote.AbstractProtocolHandler init信息:   初始化ProtocolHandler [“ajp-bio-8009”] Okt 17,2013 8:34:41 PM   org.apache.catalina.startup.Catalina load信息:初始化   处理时间为561 ms Okt 17,2013 8:34:41 PM   org.apache.catalina.core.StandardService startInternal信息:   开始服务Catalina Okt 17,2013 8:34:41 PM   org.apache.catalina.core.StandardEngine startInternal Information:   启动Servlet引擎:Apache Tomcat / 7.0.12 Okt 17,2013 8:34:42 PM   org.apache.catalina.core.StandardContext listenerStart Schwerwiegend:   配置类的应用程序侦听器时出错   org.apache.struts2.tiles.StrutsTilesListener   java.lang.NoClassDefFoundError:   org / apache / tiles / web / startup / TilesListener at   java.lang.ClassLoader.defineClass1(Native Method)at   java.lang.ClassLoader.defineClass(未知来源)at   java.security.SecureClassLoader.defineClass(未知来源)at   org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818)     在   org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148)     在   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)     在   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)     在   org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)     在   org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)     在   org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638)     在   org.apache.catalina.core.StandardContext $ 1.call(StandardContext.java:5204)     在   org.apache.catalina.core.StandardContext $ 1.call(StandardContext.java:5199)     在java.util.concurrent.FutureTask.run(未知来源)at   java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)at   java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)at   java.lang.Thread.run(未知来源)引起:   抛出java.lang.ClassNotFoundException:   org.apache.tiles.web.startup.TilesListener at   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)     在   org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)     ......还有17个

     

Okt 17,2013 8:34:42 PM org.apache.catalina.core.StandardContext   listenerStart Schwerwiegend:跳过安装应用程序监听器   由于之前的错误,Okt 17,2007 8:34:42 PM   org.apache.catalina.core.StandardContext startInternal Schwerwiegend:   Error listenerStart Okt 17,2013 8:34:42 PM   org.apache.catalina.core.StandardContext startInternal Schwerwiegend:   由于之前的错误,上下文[/ Struts4Scoodle]启动失败   17,2013 8:34:42 PM org.apache.coyote.AbstractProtocolHandler启动   信息:启动ProtocolHandler [“http-bio-8080”] Okt 17,2013   8:34:42 PM org.apache.coyote.AbstractProtocolHandler启动   信息:启动ProtocolHandler [“ajp-bio-8009”] Okt 17,2013   下午8:34:42 org.apache.catalina.startup.Catalina start信息:   服务器启动时间为739 ms`

这是我第一次使用Tiles而且我没有得到它。非常感谢你。

2 个答案:

答案 0 :(得分:0)

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.1</version>
</dependency>

删除以上依赖项。 struts2-tiles-plugin将自动传递tile依赖项,并且版本为2. *而不是3. *

答案 1 :(得分:0)

导入库jsp-api-2.1 因为struts2-tiles-plugin依赖于它