蛋糕店网站设计模板,湖南长沙特色简介,qq外国注册网站,百度网盘有多大的免费空间1.在初始化时保存ApplicationContext对象
2.通过Spring提供的utils类获取ApplicationContext对象
3.继承自抽象类ApplicationObjectSupport
4.继承自抽象类WebApplicationObjectSupport
5.实现接口ApplicationContextAware
6.通过Spring提供的ContextLoader 来说一下实现接…1.在初始化时保存ApplicationContext对象
2.通过Spring提供的utils类获取ApplicationContext对象
3.继承自抽象类ApplicationObjectSupport
4.继承自抽象类WebApplicationObjectSupport
5.实现接口ApplicationContextAware
6.通过Spring提供的ContextLoader 来说一下实现接口的方法
Component
public class example implements ApplicationContextAware {private static ApplicationContext context;Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {context applicationContext;}example(){}public static TypeHandler createHandler(Type type) throws Exception{if(typenull){throw new Exception(handler type is null);}return (TypeHandler) context.getBean(type.getShortName()Handler);}}
实现接口之后getBrean时要实现类型转换