比如我有个类的方法,是需要在该web应用启动后自动加载的,在spring下应该如何写?
我现在是在web.xml里配置了自启动的servlet。但是这个servlet无法调用spring里配置的bean,WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext())
的方法,然后用getBean的方法,确提示找不到该bean,但是在web里是可以调用该bean的,该怎么做?
我现在是在web.xml里配置了自启动的servlet。但是这个servlet无法调用spring里配置的bean,WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext())
的方法,然后用getBean的方法,确提示找不到该bean,但是在web里是可以调用该bean的,该怎么做?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货