在Struts或別的框架中集成Spring的時候,Spring向我們提供了獲得context的方法 getApplicationContext,那在jsp中如何獲得呢?
ApplicationContext?ctx?=?WebApplicationContextUtils.getRequiredWebApplicationContext
(this.getServletConfig().getServletContext());
建議在項目中開發(fā)的時候提供一個singleton對外公布統(tǒng)一的applicationContext,畢竟不是每個人都一定能獲得web環(huán)境或servlet.