1、确保项目目录正确
2、到web.xml中添加如下配置
<!--
Spring官方文档中规定,如果在上下文中没有指定contextConfigLoction配置文件的位置,
则会默认去WEB-INF中去寻找对应的配置文件。
项目中没有用到 applicationContext.xml文件,
所以在web.xml中添加一个空的contextConfigLocation就可以了
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</context-param>
3、查看、修改iml文件配置的情况
如下所示,都是此项目配置的资源路径、web根目录等配置
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>