thymeleaf 无法正常解析页面(本地可以正常访问某个请求,并可以返回页面,但服务端访问出现找不到模板)

Posted Coder,Not hair

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thymeleaf 无法正常解析页面(本地可以正常访问某个请求,并可以返回页面,但服务端访问出现找不到模板)相关的知识,希望对你有一定的参考价值。

thymeleaf 无法正常解析页面(本地可以正常访问某个请求,并可以返回页面,但服务端访问出现找不到模板)

出错提示:

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

解决方案:

之前的:

modelAndView.setViewName("/admin/index");

应该改成

modelAndView.setViewName("admin/index");

去掉/就可以正常路由了。

以上是关于thymeleaf 无法正常解析页面(本地可以正常访问某个请求,并可以返回页面,但服务端访问出现找不到模板)的主要内容,如果未能解决你的问题,请参考以下文章