web.xml中配置固定数据
在web.xml单个servlet中配置的数据的存取
存:
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>CreateServletContext</servlet-name>
<servlet-class>com.zh.CreateServletContext</servlet-class>
<!-- 这个是配置文件用的 只对这个servlet有用 -->
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</servlet>
取:
//取出配置文件
String encoding=this.getServletConfig().getInitParameter("encoding");
out.println("encoding="+encoding); 在web.xml中整个servlet中配置的数据的存取
存:
<!-- 如果让所有的servlet可以访问,可以这样设置 -->
<context-param>
<param-name>name</param-name>
<param-value>zhouhai</param-value>
</context-param>
注意: 这个是放在<servlet></servlet>外面的
取:
String name=this.getServletContext().getInitParameter("name");
out.println("name="+name);
web.xml中配置固定数据的更多相关文章
- web.xml中配置log4j
1.将 commons-logging.jar和 log4j.jar加入你的项目中:2.在src/下创建log4j.properties|log4j.xml文件:3.在web.xml中配置log4j的 ...
- web.xml中配置Spring中applicationContext.xml的方式
2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...
- web.xml中配置启动时加载的servlet,load-on-starup
web.xml中配置启动时加载的servlet,load-on-starup 使用servlet来初始化配置文件数据: 在servlet的配置当中,<load-on-startup>1&l ...
- 在web.xml中配置error-page
在web.xml中配置error-page 在web.xml中有两种配置error-page的方法,一是通过错误码来配置,而是通过异常的类型来配置,分别举例如下: 一. 通过错误码来配置error ...
- web.xml 中配置了error-page但不起作用问题
问题: 在web.xml 中配置了 error-page,但是好像不起作用,就是跳转不到指定的页面. 配置信息如下: <!-- 400错误 --> <error-page> & ...
- struts2 在 Action 或 Interceptor 中获取 web.xml 中配置的 <context-param> 参数 (这是我的第一篇博文,哈哈。)
最近为了改一个问题,想加一个控制开关,就在web.xml 中配置了一个 <context-param> 参数,并在 Action 或 Interceptor 中获取参数值. 1.在 web ...
- 在web.xml中配置监听器来控制ioc容器生命周期
5.整合关键-在web.xml中配置监听器来控制ioc容器生命周期 原因: 1.配置的组件太多,需保障单实例 2.项目停止后,ioc容器也需要关掉,降低对内存资源的占用. 项目启动创建容器,项目停止销 ...
- 在哪个web.xml中配置welcome页面
是在tomcat的web.xml中配置,而不是在你的%web-project-root%/WEB-INF/web.xml中! 示例 <welcome-file-list> <welc ...
- 在web.xml中配置SpringMVC
代码如下 <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.spr ...
随机推荐
- 聚合数据天气预报API-ajax 通过城市名取数据
如需要,可申请聚合数据天气预报API:https://www.juhe.cn/docs/api/id/39,并生成AppKey. 接口地址:http://v.juhe.cn/weather/index ...
- Ubuntu 14.04 部署 CEPH集群
注:下文的所有操作都在admin节点进行 1.准备三台虚拟机,其中一台作为admin节点,另外两台作为osd节点,并相应地用hostname命令将主机名修改为admin,osd0,osd1,最后修改/ ...
- [ZZ]最小化不可重现的bug
http://testerhome.com/topics/577 原文请见 Minimizing Unreproducible Bugs 不能重现的 bug 是我的灾难.我常常找到一个bug 后来又听 ...
- codeforces 484D D. Kindergarten(dp)
题目链接: D. Kindergarten time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 二分匹配之最大权值匹配算法---KM模板
百科:http://baike.baidu.com/link?url=vbM3H4XmfrsWfP-epdlR2sVKSNzOq4hXnWDqm5uo8fd7VWsF2SmhDV35XyVUDvVjv ...
- AC日记——舒适的路线 codevs 1001 (并查集+乱搞)
1001 舒适的路线 2006年 时间限制: 2 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 查看运行结果 题目描述 Description Z小镇是 ...
- Loadrunner:场景运行较长时间后报错:Message id [-17999] was not saved - Auto Log cache is too small to contain the message.
loadrunner运行时间较长后,跑数据过程老是失败,有如下error: Message id [-17999] was not saved - Auto Log cache is too smal ...
- 一篇搞定RSA加密与SHA签名|与Java完全同步
基础知识 什么是RSA?答:RSA是一种非对称加密算法,常用来对传输数据进行加密,配合上数字摘要算法,也可以进行文字签名. RSA加密中padding?答:padding即填充方式,由于RSA加密算法 ...
- 利用exif.js解决ios手机上传竖拍照片旋转90度问题
html5+canvas进行移动端手机照片上传时,发现ios手机上传竖拍照片会逆时针旋转90度,横拍照片无此问题:Android手机没这个问题. 因此解决这个问题的思路是:获取到照片拍摄的方向角,对非 ...
- CSS选择器的权重与优先规则
权重顺序 “important > 内联 > ID > 类 > 标签 | 伪类 | 属性选择 > 伪对象 > 继承 > 通配符”. 原文:http://w ...