
出现这种情况的原因是静态资源没有打包到jar
如何解决
ps:本编博客不是解决thymeleaf模板引擎的问题
第一步 在pom.xml文件的<build></build>标签下添加如下
<resources> <resource> <!--打包成jar静态资源必须指明路径,打包成war可以不用--> <directory>${basedir}/src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <includes> <include>/</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>/</include> </includes> </resource> </resources>
重新打包成jar并运行,如何还是不成功进入到第二步。
第二步 检查application.properties文件里的view前后缀
spring.mvc.view.prefix=jsp/ spring.mvc.view.suffix=.jsp
第三步 检查你的springboot版本是否大于1.4.2,
如果大于1.4.2resource是不管用的,改小就行了,我的是1.3.6
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/231961.html原文链接:https://javaforall.net
