比如我有个类的方法,是需要在该web应用启动后自动加载的,在spring下应该如何写? 
我现在是在web.xml里配置了自启动的servlet。但是这个servlet无法调用spring里配置的bean,WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()) 
的方法,然后用getBean的方法,确提示找不到该bean,但是在web里是可以调用该bean的,该怎么做?

解决方案 »

  1.   

    web.xml中配置一个listener如下:
    <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
      

  2.   

    按有几个群,你不妨加进去,可以和大家一起讨论啊.........46986340,28039577,4804620               
    在那里看看有无能回答你的,谢谢,LZ,甭忘了给俺分哦,谢谢LZ
      

  3.   


    web.xml中配置一个listener如下:
    <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener>