【问题标题】:Spring-Boot template resolution fails when WAR is deployed部署WAR时Spring-Boot模板解析失败
【发布时间】:2017-04-04 10:00:31
【问题描述】:

我的 Spring-Boot 应用在通过 Eclipse IDE(安装了 S.T.S. 3.8.4)和嵌入式 tomcat 服务器运行时运行良好。

我将其打包为 WAR 并部署到本地 Tomcat 服务器。

访问应用程序时,返回一个空白页面。我在 Tomcat 日志中发现了异常(在 Windows 上,C:\<path-to-tomcat>\logs)尝试解析 Thymeleaf 模板时抛出异常:

2017-04-04 12:33:36.602 ERROR 5724 --- [io-12080-exec-7] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-12080-exec-7] Exception processing template "home": Error resolving template "common/layout", template might not exist or might not be accessible by any of the configured Template Resolvers (template: "home" - line 5, col 7)

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "common/layout", template might not exist or might not be accessible by any of the configured Template Resolvers (template: "home" - line 5, col 7)
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:865) ~[thymeleaf-3.0.2.RELEASE.jar:3.0.2.RELEASE]

【问题讨论】:

    标签: spring tomcat spring-boot war thymeleaf


    【解决方案1】:

    问题在于文件夹名称的大小写。

    我在templates/Common/layout.html 中有我的布局片段(注意Common 中的大写C),在我看来是引用common/layout,它在IDE 中工作,但在Tomcat 服务器上部署WAR 时不起作用。可能是因为IDE忽略了大小写,而Tomcat是区分大小写的?

    在我的视图中将引用更改为文件夹的正确大小写后,它起作用了,Common/layout

    【讨论】:

      猜你喜欢
      • 2019-03-14
      • 2014-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-24
      • 2015-03-10
      • 2018-12-05
      相关资源
      最近更新 更多