web.xml读取config.properties
来源:互联网 发布:怎样做软件开发 编辑:程序博客网 时间:2024/05/20 19:32
因为项目需要,一个特别诡异的需要。
<context-param>
<param-name>xxxxxx</param-name>
<param-value>${yyyyyyy}</param-value>
</context-param>
想在web.xml这么玩, 结果打死获取不到数据,网上搜下,只见问题不见答案。
在sping.xml中经常这么玩,不明白到 web.xml中怎么就取不到了。
问题还是要解决啊,换个思路,在ContextLoaderListener中实现吧。
重写 ContextLoaderListener,初始化的时候 往上下文中塞参数
public void contextInitialized(ServletContextEvent event) {
this.contextLoader = createContextLoader();
if (this.contextLoader == null) {
this.contextLoader = this;
}
this.contextLoader.initWebApplicationContext(event.getServletContext());
event.getServletContext().setInitParameter("xxxxxxx", PropertyUtil.getString("yyyyyyy"));
}
测试下,居然也是可以的,至于有没隐患,嗯,再观察观察吧。
- web.xml读取config.properties
- config-读取web.xml
- xml读取properties配置文件,web.xml读取properties,properties格式,properties在eclipse创建
- xml读取properties配置文件,web.xml读取properties,properties格式,properties在eclipse创建
- web.config.xml设置和读取数据库
- 读取config.properties信息
- web jsp通过classes 读取config properties文件
- 配置文件:persistence.xml-----beans.xml----jdbc.properties----log4j.properties---oscache----paoding---struts.config---web.xml
- java读取config.properties配置文件
- java读取config.properties配置文件
- Java web项目中读取properties,xml文件
- 遍历读取XML文件及web.config的动态更新
- 利用xml轻松读取web.config中的用户自定义节
- Properties读取xml文件
- 读取配置文件properties xml
- web.config读取
- 读取宿主web.config
- web.config配置文件读取
- lightoj1072
- hdu 3065 ac自动机
- 机器学习中的数学(1)——怎样形象的理解卷积
- [pattest]1066. 图像过滤(15)
- CC2640R2F BLE5.0 CC2640R2&BLE5.0开发文档
- web.xml读取config.properties
- c#正则表达式 ipv4地址
- HTML5基础之代码入门
- 0.IDA-基本的反汇编算法
- python:单引号,双引号和三引号
- Linux2文件目录操作4-文件查找与定位命令
- Servlet处理登陆响应参考代码
- spark简介
- Hexo快速部署教程