zoukankan      html  css  js  c++  java
  • 关于ApplicationContext的初始化(cite)

    一、提倡的初始化方法:
    《1》在独立应用程序中,获取ApplicationContext:
              AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
             context.close();//释放资源
    《2》在web环境中,获取ApplicationContext:

          A)ServletContext servletContext = request.getSession().getServletContext();               

             ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); 

          B)String contextpath = "org.springframework.web.context.WebApplicationContext.ROOT";

             WebApplicationContext context = request.getSession().getServletContext().getAttribute(contextpath);   

    二、不提倡的方法:(这种写法不仅仅耗内存,占资源,而且如果数据库连接太多,很容易造成系统运行的缓慢甚至stop!)

            ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

  • 相关阅读:
    ssm依赖
    NSNotificationCenter详解
    Objective-C语法之代码块(block)的使用
    IOS UI UITableView
    IOS 多线程(4) --线程通讯
    IOS 多线程(3) --线程安全
    IOS 多线程(2) --NSThread
    IOS 多线程(1) --基础知识
    IOS UI TextFiled常用总结
    IOS UI TabBar标签栏的使用
  • 原文地址:https://www.cnblogs.com/Akke/p/4950878.html
Copyright © 2011-2022 走看看