Where is the exact location of spring config file and web.xml?

后端 未结 2 2107
滥情空心
滥情空心 2021-02-10 00:19

Getting the Class Not Found Exception for DispatcherServlet while rendering index.jsp which is in WEB-CONTENT/WEB-INF/jsp/index.jsp

Following are how the project is stru

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-10 00:26

    From the documentation:

    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.

    So placing abc-servlet.xml within WEB-INF should allow the dispatcher servlet to pick up your configuration.

    If you didn't want your dispatcher servlet to use the default name or wanted it to reside in another directory besides WEB-INF you would specify this configuration in web.xml. The location and name of the dispatcher servlets configuration can be changed by setting the contextConfigLocation init-param within the DispatcherServlet

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

    This information can be found within the Spring Documentation

提交回复
热议问题