0

我找不到我的应用程序有什么问题。使用支柱 2 和瓷砖。网页.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>

瓷砖.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 信息:在 java.library.path 上找不到基于 APR 的 Apache Tomcat Native 库,它允许在生产环境中获得最佳性能:C: \Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\ System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files\Java\jdk1.7.0_40;C: \apache-maven-3.1.1-bin\apache-maven-3.1.1\bin;. Okt 17, 2013 8:34:41 PM org.apache.tomcat.util.digester.SetPropertiesRule 开始警告:[SetPropertiesRule]{Server/Service/Engine/Host/Context} 将属性 'source' 设置为 'org.eclipse.jst .jee.server:Struts4Scoodle' 没有找到匹配的属性。2013 年 10 月 17 日 8:34:

Okt 17, 2013 8:34:42 PM org.apache.catalina.core.StandardContext listenerStart Schwerwiegend:由于先前的错误而跳过安装应用程序侦听器 Okt 2013 年 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: Context [/Struts4Scoodle] 由于先前的错误而启动失败 Okt 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 PM org.apache.catalina.startup.Catalina 启动信息:服务器在 739 毫秒内启动`

这是我第一次使用 Tiles,但我不明白。非常感谢。

4

2 回答 2

0

导入库 jsp-api-2.1 as struts2-tiles-plugin 对其有依赖

于 2014-01-21T11:28:12.670 回答
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 将自动传递地添加切片依赖项,并且那些具有版本 2.* 而不是 3.*

于 2013-10-17T21:16:36.200 回答