Spring中的WebAppRootListener
来源:互联网 发布:数组排序jquery 编辑:程序博客网 时间:2024/05/01 00:41
Spring中的WebAppRootListener
这个listner的作用就是监听web.xml中的配置para-name为webAppRootKey的值,比如我的web应用为tsts,那么我配置
这样一个
- <context-param>
- <param-name>webAppRootKey</param-name>
- <param-value>tsts.root</param-value>
- </context-param>
,然后再配置这样一个监听器:
- <listener>
- <listener-class>
- org.springframework.web.util.WebAppRootListener
- </listener-class>
- </listener>
。这个监听器就会在web上下文初始化的时候,调用webUtil的对应方法,首先获取到param-name对应的param-value ,然后,根据传递进去的ServletContext对象得到web的物理路径:String root = servletContext.getRealPath("/");
接着把这个param-value作为key,root作为value放到system中System.setProperty(key, root);
然后再web中可以用 System.get.....就可以得到web的跟目录的物理路径了。
之前我的做法是用一个filter,在filter的init中调用String root = servletContext.getRealPath("/");,然后再去设置对应一个常量类文件的属性。做法差不多,但是spring的做法更可以借鉴!
0 0
- Spring中的WebAppRootListener
- Spring中的WebAppRootListener
- Spring中的WebAppRootListener
- Spring中的WebAppRootListener
- Spring 中WebAppRootListener的误解
- servlet3.0 contextLoadListener和WebAppRootListener
- java.lang.ClassNotFoundException: org.springframework.web.util.WebAppRootListener
- WebAppRootListener使用的过程中遇到的问题
- [Spring]Spring中的事务管理
- Spring 中的事务处理
- Spring中的ProxyFactoryBean
- Spring中的getBean
- Spring中的Bean
- spring中的问题
- Spring 中的 AOP
- Spring中的名词概念
- Spring中的WebApplicationContext
- Spring中的数据绑定
- POJ Supermarket
- cuda学习笔记之异步并行执行
- 借助SAP HANA实现文本分析和文本挖掘
- gethibernatetemplate的find方法大全
- linux bind: Address already in use(Z)
- Spring中的WebAppRootListener
- php中如何获取文本文件并删除最后一个字符。
- Hibernate三种状态;query查询;ResultTransformer转换为pojo对象;可以将query语句写在xml中;Criteria查询;ProjectionList总和/f分组等函数
- 正则表达式
- struts2中的文件上传与下载
- Linux 命令(常用)(1.6.1)
- Extjs4--简单的Grid表格
- COJ - 1005 - Rent your Airplane and make Money 题解
- HDU 3336 记忆化搜索