未知标记切片:insertAttribute

时间:2018-01-30 16:22:22

标签: eclipse struts2 tiles

我尝试使用磁贴在div中显示jsp页面,但eclipse向我显示如下警告: Unknown tag (tiles:insertAttribute)

这是我的 index.jsp

<nav class="navbar navbar-inverse">     
    <tiles:insertAttribute name="header" />
</nav>
<!--  Main container  -->
<div class="container-fluid text-center">
    <div class="row content">
<!-- Right menu -->     
        <div class="col-sm-2 sidenav">
            <tiles:insertAttribute name="menu" />
        </div>

这是我的 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="index" template="/index.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="/Header.jsp" />
        <put-attribute name="menu" value="/Menu.jsp" />
        <put-attribute name="body" value="/Body.jsp" />
        <put-attribute name="footer" value="/Footer.jsp" />
    </definition>

这是我的 web.xml

<listener>
    <listener- class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<context-param>
    <param-name>tilesDefinitions</param-name>
    <param-value>/WEB-INF/tiles.xml</param-value>
</context-param>

编辑:这是我的 pom.xml 的一部分,如果需要更多信息,请问我。

http://maven.apache.org/maven-v4_0_0.xsd">     4.0.0     com.cice.adelagd     proyectoNUS     战争     0.0.1-SNAPSHOT     proyectoNUS Maven Webapp     http://maven.apache.org     

    <dependency>
        <groupId>org.dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jta_1.1_spec</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.1-api</artifactId>
        <version>1.0.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.jboss</groupId>
        <artifactId>jandex</artifactId>
        <version>2.0.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.22.0-GA</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.3.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>3.5.2</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.44</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.5.14.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.12.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>5.0.1.Final</version>
    </dependency>
</dependencies>
<build>
    <finalName>proyectoNUS</finalName>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.4.7.v20170914</version>
            <configuration>
                <webApp>
                    <contextPath>/${project.build.finalName}</contextPath>
                </webApp>
                <stopKey>CTRL+C</stopKey>
                <stopPort>8999</stopPort>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <scanTargets>
                    <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget>
                </scanTargets>
            </configuration>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

您误解了项目使用的文件。 Datacenter: dc1 =============== Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack DN 10.249.55.108 283.54 KiB 256 100.0% 619242db-f0bd-4492-aeb6-2bb0ebfe4733 rack1 Datacenter: dc2 =============== Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns (effective) Host ID Rack UN 10.249.55.111 294.75 KiB 256 100.0% 6ebe897e-94e3-44e5-99dc-055beb633e74 rack1 不应包含任何菜单内容。它应该更好地命名为index.jsphead tile。

要在JSP中使用menu前缀标记,您应该定义一个taglib:

tiles: