首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Spring-boot胸腺叶从类路径加载HTML文件

Spring-boot胸腺叶从类路径加载HTML文件
EN

Stack Overflow用户
提问于 2015-04-07 04:47:10
回答 1查看 19.8K关注 0票数 16

我有一个多模块的项目结构,比如:

代码语言:javascript
运行
复制
- application (parent module)
--- boot (web-app)
----- src/main/resources/templates/layout.html

---- todo (jar file)
----- src/main/resources/templates/home.html

在我的控制器上:

代码语言:javascript
运行
复制
@RequestMapping(value = "/home")
public String home() {
    return "todo/home";
}

我收到如下错误消息:

代码语言:javascript
运行
复制
Error resolving template "todo/home", template might not exist or
might not be accessible by any of the configured Template 
Resolvers]

为了在类路径上搜索模板,需要为spring配置一些专门的配置吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-19 21:50:36

添加以下属性可以解决我的问题:

代码语言:javascript
运行
复制
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29479403

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档