简体   繁体   中英

JspTaglib [“http://tiles.apache.org/tags-tiles”] is undefined: It cannot be assigned to tiles

I'm doing an update conversion to a very old Java project and converting it under Spring Boot. But, I'm having difficulties getting the front pages to be render as they were built with Struts 2, .ftl using Apache Tiles.

For some reason I get this error JspTaglibs is undefined. It cannot be assigned to tiles, when it tries to load the page.

I have checked that I had all the jar files necessary (I think?), but as I'm not at all familiar with .ftl or tiles I can't help myself to figure out what is the problem.

Dependencies:

    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-api</artifactId>
        <version>2.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>2.2.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.1.8.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-tiles-plugin</artifactId>
        <version>2.1.8</version>
    </dependency>

    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.15</version>
    </dependency>

I'm assigning the tiles to the page like this

<#assign tiles=JspTaglibs["http://tiles.apache.org/tags-tiles"]>

<@tiles.insertAttribute name="navigation" /> 

<@tiles.insertAttribute name="body" /> 

Add this to your web.xml or bootstrup this servlet with Spring Boot.

<servlet>
    <servlet-name>jspSupportServlet</servlet-name>
    <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
    <load-on-startup>5</load-on-startup>
</servlet>

It's needed to integrate Freemarker with Tiles in Struts 2.

You can use struts-examples tiles project that demonstrates such integration. Also upgrade to the latest Struts version.

The sensible part of this project you can find in pom.xml .

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <struts2.version>2.5.8</struts2.version>
</properties>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM