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