If you are using Thymeleaf
as with Spring, I assume you have something like
<bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> <property name="prefix" value="/WEB-INF/templates/" /> <property name="suffix" value=".html" /> <property name="templateMode" value="HTML5" /> </bean> <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"> <property name="templateResolver" ref="templateResolver" /> </bean> <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver"> <property name="templateEngine" ref="templateEngine" /> </bean>
In other words, your templates should be located in the folder specified in the ServletContextTemplateResolver
prefix
property. In the above example, this is /WEB-INF/templates
. Therefore, they must be in /src/main/webapp/WEB-INF/templates
.
If you do not use ServletContextTemplateResolver
, but use ClassLoaderTemplateResolver
, you can place them anywhere in your path to the application class and specify it in the bean properties. There is also a FileTemplateResolver
in which you can specify an absolute path anywhere in your file system.
When creating an application using Eclipse (maven plugin) folders exist
/src /main /webapp /WEB-INF /templates /some-template.html /index.html /java /com /yourcompany /Main.java /resources /some-properties.properties
maven will generate the following
/WEB-INF /templates /some-template.html /index.html /classes /com /yourcompany /Main.class /some-properties.properties
As an extended .war
and specify this in your servlet container, for example. Tomcat
source share