比如我有个类的方法,是需要在该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的,该怎么做?
解决方案 »
- java如何操作shp文件
- 【分享】怎么设置使MyEclipse的代码提示功能一样能像Microsoft Visual Studio的代码提示功能
- 有没有好点的ajax的电子书推荐啊
- struts表格隐藏某一列的值
- 如何用jsp实现字符串连接?
- servlet过滤器能不能实现对所有请求的过滤,防止非法字符\请求等
- 请问如何得到链接过来的上一页面的地址如“/Expert/PostNew.asp?room=5409”
- 大家好,请帮帮小弟
- web.xml文件的配置
- 100分求解 :如何打印隐藏frame中的页面?
- 关于jsporacle10g的问题
- IE窗口关闭后,为什么Singleton的实例没有被销毁
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
在那里看看有无能回答你的,谢谢,LZ,甭忘了给俺分哦,谢谢LZ
web.xml中配置一个listener如下:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>