求助大牛SpringContextPublisher ..

wygxz 发布于 2012/09/03 09:29
阅读 551
收藏 0

【华为云1024程序员节·向云而生】预约直播 抽14件华为电子产品礼包!>>>

@你懂得 你好,想跟你请教个问题:

SpringContextPublisher 下的applicationContext 总是为null、

public class SpringContextPublisher implements ApplicationContextAware {

private static ApplicationContext applicationContext;  

public void setApplicationContext(ApplicationContext arg0)

throws BeansException {

this.applicationContext = applicationContext; 

}

public Object getBean(String name) throws BeansException {   

          return applicationContext.getBean(name);   

}

}


加载中
0
ddatsh
ddatsh

web.xml

add

<context-param>

    <param-name>contextInitializerClasses</param-name>

  <param-value>com.xxx.XXApplicationContextInitializer</param-value>

</context-param>


w
wygxz
谢谢、
0
w
wygxz

<bean class="SpringContextPublisher"></bean>

哈哈。忘注入了、

返回顶部
顶部