后来我在网上找了一下servlet怎样去访问spring容器,在网上有一篇例子我把代码粘贴下来,方便日后遇到相同问题还在网上去找答案:
WebApplicationContext ctx = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext());
只要这样使用servlet就能够轻松访问spring容器了!O(∩_∩)O
WebApplicationContext ctx = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext());