使用taglib获取错误uri =" http://tiles.apache.org/tags-tiles"

时间:2014-12-18 08:56:52

标签: java spring maven tiles apache-tiles

我在pom.xml中添加了tile依赖项。

当我添加此行时,我的jsp页面出现错误<%@ taglib uri =" http://tiles.apache.org/tags-tiles"前缀="瓷砖" %GT;

<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.nated.app.migration</groupId>
<artifactId>nated</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>nated Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
    <spring.version>3.1.1.RELEASE</spring.version>
    <jdk.version>1.6</jdk.version>
    <jstl.version>1.2</jstl.version>
    <junit.version>4.11</junit.version>
    <tiles.version>2.2</tiles.version>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>

    <!-- jstl -->
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>
    <!--Spring dependency starts -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <!--Spring dependency Ends -->
    <!-- MySQL Driver -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.0.5</version>
    </dependency>

    <!-- Tiles -->
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-api</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-servlet</artifactId>
        <version>${tiles.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-template</artifactId>
        <version>${tiles.version}</version>
    </dependency>
</dependencies>

<build>
    <finalName>nated</finalName>
    <!-- Set JDK Compiler Level -->
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

现在我正在运行mvn eclipse:eclipse,它唯一下载的pom文件不是jar文件请看下面的图像-1和图像2.这就是我收到错误的原因,请参阅img-3 Image-1

image-2

img-3

2 个答案:

答案 0 :(得分:0)

查看maven central(http://search.maven.org/#search|gav|1|g%3A%22org.apache.tiles%22%20AND%20a%3A%22tiles-api%22),我无法在版本2.2中找到tiles-api。

实际上,所有tile依赖都是如此。

尝试改为使用2.2.0(或2.2.1或2.2.2)代替:

<properties>
    ...
    <tiles.version>2.2.0</tiles.version>
</properties>

答案 1 :(得分:0)

我看不到您的整个JSP代码,除了上面的答案外,还要确保您在此jsp中引用的所有页面都具有

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>

页面顶部,否则将无法加载。