1.web.xml
监听器
<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 阅读(540)
评论(0) 编辑 收藏 所属分类:
Spring