首页 > 其他分享> > template might not exist or might not be accessible by any of the configured Template Resolvers
template might not exist or might not be accessible by any of the configured Template Resolvers
作者:互联网
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [xx], template might not exist or might not be accessible by any of the configured Template Resolvers
错误原因
模板不存在或者找不到任何已配置的模板解析程序可以解析模板
解决方案
- 模板不存在
在对应的Controller
类的方法中,在src/main/resources/templates
目录下检查返回的模板是否存在
- 返回字符串
返回字符串将Controller
类中@Controller
注解改为@RestController
注解
package com.spring.boot.login.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class LoginController {
@GetMapping("/")
public String login() {
return "login";
}
}
- 模板中是否存在thymeleaf语句错误
删去对应的th:
语句
- 模板中未添加thymeleaf命名空间
xmlns:th="http://www.thymeleaf.org"
将thymeleaf
添加到<html>标签中
标签:accessible,Resolvers,Controller,thymeleaf,import,org,might,模板 来源: https://blog.csdn.net/qq_44486439/article/details/115220995