Thymeleaf + Spring Boot:解析模板时出错
Thymeleaf + Spring Boot: Error resolving template
我有一个基本的 Spring 启动应用程序。使用 Spring 初始化程序,嵌入 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
看起来您 return 视图名称带有前导斜杠 (/
)。只是 return pecador/login/login
它应该在两种环境下都能工作。
检查这个:https://github.com/spring-projects/spring-boot/issues/1744
我有一个基本的 Spring 启动应用程序。使用 Spring 初始化程序,嵌入 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
看起来您 return 视图名称带有前导斜杠 (/
)。只是 return pecador/login/login
它应该在两种环境下都能工作。
检查这个:https://github.com/spring-projects/spring-boot/issues/1744