出现问题提示Could not open ServletContext resource [/WEB-INF/spring-security.xml]
事实上,我已经使用classpath:spring-security.xml指定了spring-security.xml的位置了,为什么出现这种问题呢,在spring的官方文档中,我找到了答案
Upon initialization of a DispatcherServlet
, Spring MVC looks for a file named [servlet-name]-servlet.xml
in the WEB-INF
directory of your web application and creates the beans defined there, overriding the definitions of any beans defined with the same name in the global scope.
Consider the following DispatcherServlet
Servlet configuration (in the web.xml
file):
<web-app> <servlet> <servlet-name>golfing</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>golfing</servlet-name> <url-pattern>/golfing/*</url-pattern> </servlet-mapping> </web-app>
With the above Servlet configuration in place, you will need to have a file called /WEB-INF/
golfing-servlet.xml
in your application; this file will contain all of your Spring Web MVC-specific components (beans).