正在加载图片...
的配置文件放在web-inf/c1 asses/ spring目录下--> /WEB-INE/spring/*.xml </param-value> <l⊥ stener> <1⊥ stener-c1ass> org. springframework web context. ContextLoaderlistener </1⊥ stener> 上述代码的意义很简单,通过 Context loader Listener调用 context-param中所定义的 Spring配置文件,进行初始化工作 将 Spring的 ApplicationContext放到内存 将 Spring的上下文放到内存,方便程序调用 通过 Servlet将 Spring的上下文放到内存 public class SmeStarTer extends Http servlEt private static WebApplication Context context =null ∥上下文环境静态类 南执行初始化动作。 *aseejavax.servlethttpHttpservlet#<clinito public void init(javax. servlet Servlet Config config)throws javax. servlet Servlet Exception i 初始化动作 ontext= WebApplicationContextUtils get WebApplication Context(config. getServletContexto) Application Context set Context( context)<!—Spring的配置文件放在Web-inf/classes/spring目录下--> /WEB-INF/spring/*.xml </param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> 上述代码的意义很简单,通过 ContextLoaderListener 调用 context-param 中所定义的 Spring 配置文件,进行初始化工作。 将 Spring 的 ApplicationContext 放到内存 将 Spring 的上下文放到内存,方便程序调用 通过 Servlet 将 Spring 的上下文放到内存 public class SMEStarter extends HttpServlet { private static WebApplicationContext context = null; // 上下文环境静态类 /** * 执行初始化动作。 * @see javax.servlet.http.HttpServlet# <clinit>() */ public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException { super.init(config); //初始化动作 ontext = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); ApplicationContext.setContext(context); } /* * (非 Javadoc) * @see javax.servlet.Servlet#destroy()
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有