1.web.xml
監(jiān)聽器
?<listener>
??????? <listener-class>
??????????? org.springframework.web.context.ContextLoaderListener
??????? </listener-class>
??? </listener>
在servlet上下文配置spring的配置文件
?<context-param>
??????? <param-name>contextConfigLocation</param-name>
??????? <param-value>
??????????? /WEB-INF/config/hibernate/applicationContext-hibernate.xml
??????????? /WEB-INF/config/spring/applicationContext-spring.xml
??????????? <!--/WEB-INF/config/spring/acegi-security-common.xml-->
??????? </param-value>
??? </context-param>
2.得到Spring Bean
?? public class test extends action
?{
?? private static ApplicationContext ctx = null;
?? public Object getBean(String name)
?? if(ctx == null)
??????? {
??????????? ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(servlet.getServletContext());
??????? }
??????? return ctx.getBean(name);
??? }
}
posted on 2006-06-19 14:44
Dragonofson 閱讀(550)
評論(0) 編輯 收藏 所屬分類:
Spring