Tiles - Mixing JSP and TL attiributes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Tiles - Mixing JSP and TL attiributes

Eric Francis
I am trying to construct a page using tiles that contains both elements from a jsp and a TL page.

This is my tiles xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
        <definition name="baseLayout" template="thymeleaf/layout/layout.html" templateType="thymeleaf" >
                <put-attribute name="header" value="jsp/layout/header.jsp" type="jsp" />
                <put-attribute name="body" value="" />       
        </definition>
        <definition name="welcome" extends="baseLayout">
                <put-attribute name="body" value="thymeleaf/welcome.html" type="thymeleaf"/>
        </definition>
</tiles-definitions>

Is this the correct way to mix and match?
Reply | Threaded
Open this post in threaded view
|

Re: Tiles - Mixing JSP and TL attiributes

Eric Francis
Ok, I found an error. My JSP locations must give their full locations. so "/WEB-INF/jsp/layout/header.jsp".

Is there a way to shorten the locations that I have?

This is my only resolver in my config:
@Bean
        public ServletContextTemplateResolver templateResolver() {
                ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver();
                templateResolver.setPrefix("/WEB-INF/");
                templateResolver.setTemplateMode("HTML5");
                return templateResolver;
        }

And this is my edited tiles definition:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
        <definition name="baseLayout" template="thymeleaf/layout/layout.html" templateType="thymeleaf" >
                <put-attribute name="header" value="" />
                <put-attribute name="body" value="" />       
        </definition>
        <definition name="welcome" extends="baseLayout">
                <put-attribute name="body" value="thymeleaf/welcome.html" type="thymeleaf"/>
                <put-attribute name="header" value="/WEB-INF/jsp/layout/header.jsp" type="jsp" />
        </definition>
</tiles-definitions>


I know that I can make the .html path easier to resolve. Can I set up an alternate resolver to make the jsp's easier to resolve?
Reply | Threaded
Open this post in threaded view
|

Re: Tiles - Mixing JSP and TL attiributes

danielfernandez
Administrator
dadoprso wrote
I know that I can make the .html path easier to resolve. Can I set up an alternate resolver to make the jsp's easier to resolve?
JSPs are resolved by Tiles itself, not thymeleaf. So there is no way Thymeleaf can help in that. Sorry.
Reply | Threaded
Open this post in threaded view
|

Re: Tiles - Mixing JSP and TL attiributes

Eric Francis
Ok, thanks!