相关疑难解决方法(0)

Spring-boot thymeleaf从classpath加载HTML文件

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

- application (parent module)
--- boot (web-app)
----- src/main/resources/templates/layout.html

---- todo (jar file)
----- src/main/resources/templates/home.html
Run Code Online (Sandbox Code Playgroud)

在我的控制器上:

@RequestMapping(value = "/home")
public String home() {
    return "todo/home";
}
Run Code Online (Sandbox Code Playgroud)

我收到如下错误消息:

Error resolving template "todo/home", template might not exist or
might not be accessible by any of the configured Template 
Resolvers]
Run Code Online (Sandbox Code Playgroud)

是否需要配置专门用于spring的东西来在类路径上搜索模板?

UPDATE

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

- application (parent module)
--- boot (web-app)
----- src/main/resources/templates/layout.html

---- todo (jar file)
----- src/main/resources/templates/home.html
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

14
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

spring ×1

spring-boot ×1