{"id":203902,"date":"2025-05-22T12:59:59","date_gmt":"2025-05-22T04:59:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203902\/"},"modified":"2025-05-22T12:59:59","modified_gmt":"2025-05-22T04:59:59","slug":"spring-boot-%e5%b0%8f-demo-%e4%b8%ad%e5%87%ba%e7%8e%b0-error-resolving-template-%e9%94%99%e8%af%af%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3-thymeleaf-%e6%a8%a1%e6%9d%bf%e5%bc%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203902\/","title":{"rendered":"Spring Boot \u5c0f demo \u4e2d\u51fa\u73b0 \u201cError resolving template\u201d \u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3 Thymeleaf \u6a21\u677f\u5f15\u64ce\u65e0\u6cd5\u627e\u5230\u6216\u8bbf\u95ee\u6a21\u677f\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Spring Boot \u5c0f demo \u4e2d\u51fa\u73b0 \u201cError resolving template\u201d \u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3 Thymeleaf \u6a21\u677f\u5f15\u64ce\u65e0\u6cd5\u627e\u5230\u6216\u8bbf\u95ee\u6a21\u677f\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u5411\u5927\u5bb6\u4ecb\u7ecd\u300aSpring Boot \u5c0f demo \u4e2d\u51fa\u73b0 \u201cError resolving template\u201d \u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3 Thymeleaf \u6a21\u677f\u5f15\u64ce\u65e0\u6cd5\u627e\u5230\u6216\u8bbf\u95ee\u6a21\u677f\uff1f\u300b\uff0c\u4e3b\u8981\u5305\u62ec\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241130\/1732961193674ae3a92c5cb.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>spring boot \u5c0f demo \u51fa\u73b0 error resolving template \u9519\u8bef<\/strong><\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u4f5c\u8005\u5728\u6784\u5efa spring boot \u5c0f demo \u65f6\u9047\u5230\u9519\u8bef error resolving template [], template might not exist or might not be accessible by any of the configured template resolvers\u3002<\/p>\n<p><strong>\u95ee\u9898\u5206\u6790<\/strong><\/p>\n<p>\u8be5\u9519\u8bef\u8868\u660e thymeleaf \u6a21\u677f\u5f15\u64ce\u65e0\u6cd5\u627e\u5230\u6216\u8bbf\u95ee\u6307\u5b9a\u6a21\u677f\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u9700\u8981\u786e\u8ba4\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ol>\n<li>pom \u6587\u4ef6\u4e2d\u5df2\u5f15\u5165 spring boot \u7684 thymeleaf \u8d77\u59cb\u5668\uff1a<\/li>\n<\/ol>\n<pre>&lt;dependency&gt;\n    &lt;groupid&gt;org.springframework.boot&lt;\/groupid&gt;\n    &lt;artifactid&gt;spring-boot-starter-thymeleaf&lt;\/artifactid&gt;\n&lt;\/dependency&gt;<\/pre>\n<ol>\n<li>application.properties \u6587\u4ef6\u4e2d\u5df2\u914d\u7f6e thymeleaf \u89c6\u56fe\u89e3\u6790\u5668\uff1a<\/li>\n<\/ol>\n<pre>spring.thymeleaf.mode=HTML5\nspring.thymeleaf.cache=false<\/pre>\n<ol>\n<li>\u786e\u4fdd jsp \u6587\u4ef6\u6216\u5176\u4ed6\u6a21\u677f\u6587\u4ef6\u5b58\u5728\u4e8e\u6b63\u786e\u7684\u4f4d\u7f6e\uff0c\u5e76\u5728 templates \u76ee\u5f55\u4e0b\u3002<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u4fee\u6b63<\/strong><\/p>\n<p>\u4f5c\u8005\u6ca1\u6709\u63d0\u4f9b\u5b8c\u6574\u7684\u4ee3\u7801\uff0c\u56e0\u6b64\u65e0\u6cd5\u63d0\u4f9b\u5177\u4f53\u5efa\u8bae\u3002\u4f46\u662f\uff0c\u53ef\u4ee5\u6839\u636e\u4e0a\u8ff0\u68c0\u67e5\u70b9\uff0c\u68c0\u67e5\u81ea\u5df1\u7684\u4ee3\u7801\u5e76\u8fdb\u884c\u5fc5\u8981\u7684\u66f4\u6539\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aSpring Boot \u5c0f demo \u4e2d\u51fa\u73b0 \u201cError resolving template\u201d \u9519\u8bef\uff1a\u5982\u4f55\u89e3\u51b3 Thymeleaf \u6a21\u677f\u5f15\u64ce\u65e0\u6cd5\u627e\u5230\u6216\u8bbf\u95ee\u6a21\u677f\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot \u5c0f de&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203902","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203902"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203902\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}