LayoutDialect TemplateInputException

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

LayoutDialect TemplateInputException

rajkumar
I tried using LayoutDialect, following is what I did,

In dispatcher-servlet.xml,

...
<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"> 
        <property name="templateResolver" ref="templateResolver" />
        <property name="dialects">
            <set>
                <bean class="org.thymeleaf.spring3.dialect.SpringStandardDialect" />
                <bean class="nz.net.ultraq.web.thymeleaf.LayoutDialect"/>
            </set>
        </property>
</bean>
...


In login_layout,

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org" 
        xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
        <head>
                <title layout:fragment="custom-title">Custom title here</title>
        </head>
        <body>
                <div layout:fragment="content">
        </body>
...


In login page,

<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org" 
        xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
        layout:decorator="@{/decorators/login_layout}">
        <head>
        <title layout:fragment="custom-title">Practice Login</title>
        </head>
        <div layout:fragment="content">
        ...
        </div>
        ...


the controllers working fine, even for @{/decorators/login_layout} in login page, i have tested them.

but I am facing following errors, I checked and tried a lot ways but could get ride of following exception


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/Practice/decorators/login_layout", template might not exist or might not be accessible by any of the configured Template Resolvers (login:4)
....

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/Practice/decorators/login_layout", template might not exist or might not be accessible by any of the configured Template Resolvers (login:4)
....



Somebody please help me
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

Zemi
Administrator
Could you paste here your configuration for the "templateResover" bean?
The important config values are "prefix" and "suffix".

Depending on your configuration, one of the following files must exist, please check it:
  /Practice/decorators/login_layout
  /Practice/decorators/login_layout.html
  /WEB-INF/Practice/decorators/login_layout
  /WEB-INF/Practice/decorators/login_layout.html
where the base path is your deployed app directory.

Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

rajkumar
       
        <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> 
                <property name="prefix" value="/WEB-INF/viewpages/" /> 
                <property name="suffix" value=".html" /> 
                <property name="templateMode" value="HTML5" /> 
        </bean>
         
        <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"> 
                <property name="templateResolver" ref="templateResolver" />
               
                <property name="dialects">
            <set>
                <bean class="org.thymeleaf.spring3.dialect.SpringStandardDialect" />
                <bean class="nz.net.ultraq.web.thymeleaf.LayoutDialect"/>
            </set>
        </property>
               
        </bean>
       
        <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
                <property name="templateEngine" ref="templateEngine" /> 
        </bean>
       
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

Zemi
Administrator
So according to your configuration, you must have the following file
   /WEB-INF/viewpages/Practice/decorators/login_layout.html
in your webapp deployment directory. Please check it.
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

rajkumar
still same exception,

my actual physical file location of layout is

/WEB-INF/viewpages/decorators/login_layout.html

i've tried with this
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

Zemi
Administrator
So change
    layout:decorator="@{/decorators/login_layout}"
for
    layout:decorator="/decorators/login_layout"
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

rajkumar


still not getting
Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

Zemi
Administrator
Which is the exception now? It sholdn't be the same.

Reply | Threaded
Open this post in threaded view
|

Re: LayoutDialect TemplateInputException

Emanuel
Administrator
This post was updated on .
In reply to this post by rajkumar
If your decorator page is located at /WEB-INF/viewpages/decorators/login_layout.html and your prefix value is /WEB-INF/viewpages/ and your suffix value is .html then what you need to put in the layout:decorator attribute is just the missing part.  That is:

/WEB-INF/viewpages/ decorators/login_layout .html

So can you try layout:decorator="decorators/login_layout"  ? (very similar to what you last tried, just minus the leading slash.  I don't know if extra slashes are important, but it's worth a try)

[EDIT]: Ah, I just tried adding extra slashes in my own pages, and it seems they don't make a difference, so what you tried last should have actually worked.  As Zemi said, please check the exception you're getting this time, because if it's finding the page, then it should be a different exception this time.  I tried copying the code from your original post, and there are some syntax errors in there which might be causing new errors now.