org.thymeleaf.exceptions.TemplateInputException

2018/10/5 posted in  Thymeleaf

在SpringBoot中使用Thymeleaf模板,在本地打包部署完全没有问题,资源文件也都可以映射上,但是打包成jar包部署到服务器上时(CentOS7.4),就一直报org.thymeleaf.exceptions.TemplateInputException的异常

严重: Servlet.service() for servlet [dispatcherServlet] in context with path []  
threw exception [Request processing failed; nested exception is org.thymeleaf.ex  
ceptions.TemplateInputException: Error resolving template "/index", template might not exist or might not be accessible by any of the c  
onfigured Template Resolvers] with root cause  
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/index", template might not exist or might not be accessible  
 by any of the configured Template Resolvers  

最终在网上查找了解决方法,就是在return "/index";这行代码,去掉最前面的"/"就好了