views:

51

answers:

1

Hello

How to configure my web application in Eclipse (based on Servlets and deployed to Tomcat) to use Spring framework. I need only IoC container (Beans only and ApplicationContext), not Spring MVC. How to configure web.xml for this?

Regards

+5  A: 

One way is to put this in your web.xml:

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

and have applicationContext.xml in WEB-INF, or have its location configured this way (in web.xml again)

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:applicationContext.xml
    </param-value>
</context-param>
Bozho
You mean `/WEB-INF/applicationContext.xml`, right?
skaffman
@skaffman - yes, thanks. I'm always configuring it to be on classpath so I forgot the default :)
Bozho