1
https://github.com/ultraq/thymeleaf-layout-dialect에서 언급 한 바와 같이 스프링 mvc와 함께 thymeleaf 레이아웃 방언을 사용하려고했습니다. 내 스프링 서블릿은 다음과 같습니다.템플릿이 존재하지 않거나 액세스 할 수 없습니다.
<beans:bean id="templateResolver"
class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
<beans:property name="prefix" value="/WEB-INF/templates/" />
<beans:property name="suffix" value=".html" />
<beans:property name="templateMode" value="HTML5" />
</beans:bean>
<beans:bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
<beans:property name="templateResolver" ref="templateResolver" />
<!-- These lines add the dialect to Thymeleaf -->
<beans:property name="additionalDialects">
<beans:set>
<beans:bean class="nz.net.ultraq.thymeleaf.LayoutDialect" />
</beans:set>
</beans:property>
</beans:bean>
<beans:bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
<beans:property name="templateEngine" ref="templateEngine" />
<beans:property name="characterEncoding" value="UTF-8" />
</beans:bean>
저는/WEB-INF/templates /에 모든 템플릿 파일을 보관했습니다. 내가 코드를 다음 사용하면 나는 오류 다음 얻을 만들고 thymeleaf
<html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="Layout.html">
에 유혹을 사용 : 장식 = "Layout.html"코드가 어떤없이 완벽하게 작동 : 나는 레이아웃이없는 경우
[THYMELEAF] * Dialect [1 of 2]: org.thymeleaf.spring3.dialect.SpringStandardDialect
[THYMELEAF] * Prefix: "th"
[THYMELEAF] * Dialect [2 of 2]: nz.net.ultraq.thymeleaf.LayoutDialect
[THYMELEAF] * Prefix: "layout"
[THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
19:32:40,992 INFO [org.thymeleaf.TemplateEngine] (http-localhost-127.0.0.1-8080-1) [THYMELEAF] TEMPLATE ENGINE INITIALIZED
19:32:41,199 ERROR [org.thymeleaf.TemplateEngine] (http-localhost-127.0.0.1-8080-1) [THYMELEAF][http-localhost-127.0.0.1-8080-1] Exception processing template "home": Error resolving template "Layout.html", template might not exist or might not be accessible by any of the configured Template Resolvers (home:4)
19:32:41,202 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/expensemanager].[appServlet]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet appServlet threw exception: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "MainLayout.html", template might not exist or might not be accessible by any of the configured Template Resolvers (home:4)
오류. 다음은
내 프로젝트 구조를 보여주는 이미지입니다
구성을 시도했지만 여전히 동일한 오류가 발생했습니다. 내가 요청한대로 프로젝트 구조를 게시물에 추가했습니다. 제가 잘못했는지 알려주세요. – Prabhat
HTML 파일의 레이아웃은'layout : decorator = "Layout.html"이지만 폴더 구조의 파일 이름은'MainLayout.html'입니다. 어딘가에 불일치가 있습니까? 이 샘플 프로젝트를 어딘가에 업로드 할 수 있다면 한 번 살펴볼 수 있습니다. 나는 어딘가에 약간의 잘못된 설정이 있다고 생각한다. – manish
https://onedrive.live.com/redir?resid=EA49CD7184E0E40!172&authkey=!AI9iSfzen4xbBFw&ithint=file%2cwar에서 전쟁 파일을 복사했습니다. 내가 잘못 설정했는지 말해주십시오. – Prabhat