简体   繁体   English

Thymeleaf + Spring Boot:解析模板时出错

[英]Thymeleaf + Spring Boot: Error resolving template

I have a basic SpringBoot app. 我有一个基本的SpringBoot应用程序。 using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. 使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行的JAR文件。

I have this properties in the application.properties 我在application.properties有这个属性

server.contextPath=/pecador
server.port=5678

Running the through Eclipse I can access to the application and everything is fine 运行Eclipse我可以访问应用程序,一切都很好

http://localhost:5678/pecador/login

But when I deploy the application in the server and running it with the command: 但是当我在服务器中部署应用程序并使用以下命令运行它时:

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

and I try http://149.152.231.117:5678/pecador/login 我试着http://149.152.231.117:5678/pecador/login

I got this error: 我收到了这个错误:

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

and unzipping the jar the template is there, under: 并解压缩模板在那里,在:

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

It looks like you're returning the view name with a leading slash( / ). 看起来您正在使用前导斜杠( / )返回视图名称。 Just return pecador/login/login and it should work in both environments. 只需返回pecador/login/login ,它就可以在两种环境中运行。

Check this: https://github.com/spring-projects/spring-boot/issues/1744 请查看: https//github.com/spring-projects/spring-boot/issues/1744

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM