情景再现:
毕业设计是用spring tools suite(sts)写的,页面是用html写的,故使用的thymeleaf,之前用sts启动完全没问题。用idea打开,启动是没有问题,但是访问页面时就会报错。先看看项目结构吧:
页面全在WEB-INF下面,访问页面时就开始出问题了:
找到我的页面????
解决方案
通过百度及试验后,只需在我们项目的pom文件中加上以下以来即可:
<build>
<resources>
<resource>
<directory>src/main/webapp</directory>
<!--注意此次必须要放在此目录下才能被访问到 -->
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
该段配置意思是编译的时候把webapp文件放到resource下。添加后重新启动项目就可以访问了。