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 ...
随机推荐
- [转]PhoneGap使用PushPlugin插件实现消息推送
本文转自:http://my.oschina.net/u/1270482/blog/217661 http://devgirl.org/2013/07/17/tutorial-implement-pu ...
- 数据结构Java实现02----线性表与顺序表
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- Unity3D开发之搭建Mac OS开发环境
运行图 首先上几张图 IOS模拟器 坚屏 横屏 打包任务 摸索了一上午,才搞定在模拟器中运行.至于在Iphone真机中运行,虽然有开发者证书,目前还没在Xcode中配置好. 我今天第一次接触并使用MA ...
- HTML---总结
(1) margin负值能让没有宽度的盒子变大. 对于有宽度的盒子,没有浮动,只有margin-top 和margin-left 有效:如果浮动,margin-浮动方向 有效,-top有效,margi ...
- js中的return,return true,return false小结
return 函数执行到这句时会终结,并返回调用函数,而且把表达式的值作为函数的结果返回 return false 可以防止默认的事件行为.例如,默认情况下点击一个<a>元素,页面会跳转 ...
- Camera中对焦模式总结
1,相机对焦模式有以下几种: auto //自动 infinity //无穷远 macro //微距 continuous-picture //持续对焦 fixed //固定焦距 2,常见对焦模 ...
- OpenGL 4.3配置教程
OpenGL 4.3配置教程 下载开发包 需要下载的开发包主要包含如下几个组件:freeglut+glew+ OpenGL.Development.Cookbook+源码+GLM+SOIL. Open ...
- PHP基础14:$_REQUEST
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 构架高性能WEB网站的几点知识
前言: 对于构架高性能的web网站大家都很感兴趣,本文从几点粗谈高性能web网站需要考虑的问题. HTML静态化 什么是html静态化? 说得简单点,就是把所有不是.htm或者.html的页面改为.h ...
- win7(X64)+VS2013+OpenCV3.1环境配置
&1 源文件 VS2013: 链接:http://pan.baidu.com/s/1o8EKQq2 密码:open OpenCV3.1: 链接:http://pan.baidu.com/s/ ...