最近使用thymeleaf,本地启动可以正常访问,发布至服务器后报错

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [imgOcrBack/OcrCorpusTask], template might not exist or might not be accessible by any
of the configured Template Resolvers。

先上结论,检查下controller层返回的template地址,与实际xxx.html文件的大小写或名称是否拼写正确。

返回查找错误原因的过程

报错中可以看到 [imgOcrBack/OcrCorpusTask]是我的html文件访问路径

也就是controller层mapping方法返回的值

@Controller
@RequestMapping("/ocrCorpusTask")
public class ImgOcrCorpusController {
	@RequestMapping(value = "/index")
    public String index(Model model) {
        return "imgOcrBack/OcrCorpusTask";
    }
}  

但是我的html文件名称,确是ocrCorpusTask.html,发现了么,就是首字母大小写不对。这种在我的项目里,本地可以找到,服务器上就报错,不知道是不是项目中有额外配置。

因为对thymeleaf不是很感兴趣,就不深究了,问题解决就好…欢迎有懂的大佬反馈原因

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐