SpringBoot中templates文件夹访问不到解决方法
项目场景:
在控制层中跳转到templates文件夹,访问资源
问题描述:
找不到templates文件夹,浏览器中报404
@GetMapping("/create")
public ModelAndView create(@RequestParam("orderId") String orderId,
@RequestParam("returnUrl") String returnUrl) {
//发起访问
/*spring-boot-starter-freemarker 文件后缀 ftl*/
return new ModelAndView("pay/create");
}
解决方案:
需要在springboot的application.yml文件夹中配置访问路径
spring
freemarker:
suffix: .ftl #文件后缀名
template-loader-path: classpath:/templates #访问文件路径