【问题标题】:Thymeleaf + Spring Boot: Error resolving templateThymeleaf + Spring Boot:解析模板时出错
【发布时间】:2017-08-21 18:29:53
【问题描述】:

我有一个基本的 SpringBoot 应用程序。使用 Spring Initializer、嵌入式 Tomcat、Thymeleaf 模板引擎,并打包为可执行 JAR 文件。

我在application.properties中有这个属性

server.contextPath=/pecador
server.port=5678

通过Eclipse运行我可以访问应用程序,一切都很好

http://localhost:5678/pecador/login

但是当我在服务器中部署应用程序并使用命令运行它时:

sudo nohup java -jar pecadorCloudApp-0.0.1-SNAPSHOT.jar & /tmp 2>> /dev/null >> /dev/null &

我试试http://149.152.231.117:5678/pecador/login

我收到了这个错误:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/pecador/login/login", template might not exist or might not be accessible by any of the configured Template Resolvers

然后解压jar,模板就在下面:

pecadorAPP.jar/BOOT-INF/classes/templates/pecador/login/login.html

【问题讨论】:

    标签: java spring spring-mvc spring-boot ubuntu-14.04


    【解决方案1】:

    看起来您正在返回带有前导斜杠的视图名称 (/)。只需返回pecador/login/login,它应该可以在两种环境中工作。

    检查这个:https://github.com/spring-projects/spring-boot/issues/1744

    【讨论】:

      猜你喜欢
      • 2021-09-25
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      • 2018-11-30
      • 2019-05-02
      • 2020-03-14
      • 2016-01-27
      • 2016-12-21
      相关资源
      最近更新 更多