谁在spring Web应用程序中创建bean?

sab*_*sab 1 java spring spring-mvc

我知道在独立的应用程序中,我创建了一个应用程序上下文实例,这些实例又从conf文件创建bean.但是我在调​​度的servlet中看不到任何这样的代码.那么如何在Web应用程序中创建bean?

Boz*_*zho 6

所述ContextLoaderListener创建ApplicationContext(通过委托给ContextLoader)在servlet上下文,并将其存储.

所以,你必须映射ContextLoaderListener<listener>web.xml

然后,当然,ApplicationContext(WebApplicationContext在这种情况下)创建bean.