我有以下控制器:
@Controller
class ReactAppController {
@RequestMapping(value = ["/", "/{x:[\\w\\-]+}", "/{x:^(?!api$).*$}/**/{y:[\\w\\-]+}"])
fun getIndex(): String {
return "index"
}
}
我期望它应该返回index.html
文件
它的工作原理,如果我把文件index.html
下的src/main/resources/templates
和应用程序有以下依赖关系:
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
但我不想
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
在我的应用程序中,因为我不使用thymeleaf。但如果我删除此依赖-我收到whiteble错误页面。
我认为我必须以某种方式配置viewResolver,但我找不到特定的配方。有办法解决吗?
附言
这不起作用:
spring:
mvc:
view:
prefix: /templates/
suffix: .html
虽然它看起来是正确的:
1条答案
按热度按时间aoyhnmkz1#
我用来呈现网页的是:
你不必在特定的目录下有任何东西。只要在调用ClassPathResource构造函数时指定你的路径。