配置servlet以使用spring

cub*_*oft 0 java spring tomcat servlets

如何在Eclipse中配置我的Web应用程序(基于Servlet并部署到Tomcat)以使用Spring框架.我只需要IoC容器(仅限Bean和ApplicationContext),而不是Spring MVC.如何为此配置web.xml?

问候

Boz*_*zho 6

一种方法是把它放在你的web.xml:

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)

applicationContext.xmlWEB-INF这种方式配置或安置其位置(web.xml再次)

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:applicationContext.xml
    </param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)