今天新搭了项目,采用Spting和mybatis,MVC用的是Spring MVC ,配置文件采用的是之前的项目的。
在运行后访问项目时候报错了:
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
在研究后发现是web.xml缺少了Spring监听器:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
这里就有个疑问了,为什么之前项目不加这一段运行正常。
经过研究后发现是新项目加载了shiro过滤器:
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>