在Struts或别的框架中集成Spring的时候,Spring向我们提供了获得context的方法 getApplicationContext,那在jsp中如何获得呢?
建议在项目中开发的时候提供一个singleton对外公布统一的applicationContext,毕竟不是每个人都一定能获得web环境或servlet.
ApplicationContext ctx
=
WebApplicationContextUtils.getRequiredWebApplicationContext
( this .getServletConfig().getServletContext());
( this .getServletConfig().getServletContext());
建议在项目中开发的时候提供一个singleton对外公布统一的applicationContext,毕竟不是每个人都一定能获得web环境或servlet.