在jsp中获得 Spring的上下文

在jsp中获得 Spring的上下文
在Struts或别的框架中集成Spring的时候,Spring向我们提供了获得context的方法 getApplicationContext,那在jsp中如何获得呢?

ApplicationContext ctx  =  WebApplicationContextUtils.getRequiredWebApplicationContext
(
this .getServletConfig().getServletContext());

建议在项目中开发的时候提供一个singleton对外公布统一的applicationContext,毕竟不是每个人都一定能获得web环境或servlet.

你可能感兴趣的:(Spring)