Why Spring Context is loaded twice?

后端 未结 5 1146
终归单人心
终归单人心 2021-01-05 12:20

I have web project with Spring and Spring security. My web.xml:

    

        
5条回答
  •  既然无缘
    2021-01-05 12:33

    You still need a context for your servlet:

    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.

    You don't need to load it as context-param in the ContextLoaderListener though.

    Just leave the security-config.xml as context-param (it has to go there, as security is global per application), and billboard-servlet.xml as contextConfigLocation of your servlet and it should work.

提交回复
热议问题