首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

spring读取配置文件的形式

2012-09-02 
spring读取配置文件的方式一、解析classpath的应用上下文环境:ApplicationContext context new ClassPath

spring读取配置文件的方式

一、解析classpath的应用上下文环境:

ApplicationContext context = new ClassPathXmlApplicationContext("application-timer.xml");

PropertiesBean propertiesBean = (PropertiesBean) context.getBean("propertiesBean");

二、通过Spring提供的工具类获取ApplicationContext对象,可以从web-inf目录下读取xml文件:

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

ApplicationContext factory = WebApplicationContextUtils.getWebApplicationContext(servletContext);

热点排行