My Application Could not open ServletContext resource

前端 未结 5 638
梦谈多话
梦谈多话 2020-12-01 01:52

i have Eclipse Maven web project where i use Spring mvc and Spring security. When i truy to launch it, it doesn\'t suceed to intialize the context

5条回答
  •  广开言路
    2020-12-01 02:52

    Quote from the Spring reference doc:

    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...

    Your servlet is called spring-dispatcher, so it looks for /WEB-INF/spring-dispatcher-servlet.xml. You need to have this servlet configuration, and define web related beans in there (like controllers, view resolvers, etc). See the linked documentation for clarification on the relation of servlet contexts to the global application context (which is the app-config.xml in your case).

    One more thing, if you don't like the naming convention of the servlet config xml, you can specify your config explicitly:

    
        spring-dispatcher
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            /WEB-INF/spring/appServlet/servlet-context.xml
        
        1
    
    

提交回复
热议问题