私は春とタイメレフの新作です。 私はthymeleafでspring-boot Webアプリケーションを使用していますが、問題が発生しました。Thymeleafは、ブラケットで呼び出すと、私のアプリでフラグメントを解決しません。何故ですか?
<footer th:replace="fragments/footer :: footer">Footer</footer>
をしかし、私はdocumentationのように、その周りにブラケットを書くとき、私はエラーを取得: この線は完璧に動作します。
<footer th:replace="~{fragments/footer :: footer}">Footer</footer>
エラー:
There was an unexpected error (type=Internal Server Error, status=500). Error resolving template "~{fragments/footer", template might not exist or might not be accessible by any of the configured Template Resolvers (index:11)
だから何が問題になることが、私は、デフォルトスプリングのブート構成を使用しています。 のpom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
ログイン:
2017-03-01 22:47:51.585 ERROR 4014 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "index": Error resolving template "~{fragments/footer", template might not exist or might not be accessible by any of the configured Template Resolvers (index:11) 2017-03-01 22:47:51.591 ERROR 4014 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "~{fragments/footer", template might not exist or might not be accessible by any of the configured Template Resolvers (index:11)] with root cause org.thymeleaf.exceptions.TemplateInputException: Error resolving template "~{fragments/footer", template might not exist or might not be accessible by any of the configured Template Resolvers (index:11) at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.standard.fragment.StandardFragment.extractFragment(StandardFragment.java:202) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.standard.processor.attr.AbstractStandardFragmentHandlingAttrProcessor.computeFragment(AbstractStandardFragmentHandlingAttrProcessor.java:72) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.processor.attr.AbstractFragmentHandlingAttrProcessor.processAttribute(AbstractFragmentHandlingAttrProcessor.java:63) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
は私が思った、ありがとうthymeleafに慣れていませんspring-boot-starter-thymeleafはthymeleaf 3を使用します。 これを私のpom.xmlに追加しても問題ありません。 ' 3.0.2.RELEASE 2.1.1 ' –
Adam