ServletConfig和ServletContext接口
来源:互联网 发布:老是找不到东西知乎 编辑:程序博客网 时间:2024/04/30 10:21
ServletConfig接口
是 web.xml 中标签信息的内存表现,(保存标签信息的对象)和 servlet 一一对应(一个Servlet标签对应一个Servlet对象,也对应一个ServletConfig对象)
———>Servlet对象———->ServletConfig对象
应用:获取局部初始化参数
a、配置局部初始化参数 web.xml :在<servlet>标签内部。<servlet> <servlet-name>LocalParamServlet</servlet-name> <servlet-class>com.zpark.yyl.servlet.LocalParamServlet</servlet-class> <init-param> <param-name>age</param-name> <param-value>10</param-value> </init-param> </servlet> <servlet> <servlet-name>CountServlet</servlet-name> <servlet-class>com.only.CountServlet</servlet-class> <init-param> <param-name>count</param-name> <param-value>1</param-value> </init-param> </servlet>
b、读取局部初始化参数:// 获取 SerlvetConfig 对象 ServletConfig conf = super.getServletConfig(); // 读取局部初始化参数 String strAge = conf.getInitParameter("age");
ServletContext接口:(重点)
是web.xml在内存的表现,ServletContext存放了所有web.xml中的信息。和web应用 一一对应(一个应用只有一个web.xml,一个web.xml 对应一个ServletContext)
应用:获取全局初始化参数
a. 配置全局初始化参数 web.xml
在所有<serlvet>标签外面。 <context-param> <param-name>name</param-name> <param-value>zs</param-value> </context-param>
b. 读取全局初始化参数
// 获取 SerlvetContext 对象 ServletContext ctx = super.getServletContext(); // 读取全局初始化参数 String name = ctx.getInitParameter("name");
注意:
ServletConfig属于ServletContext中
0 0
- ServletConfig和ServletContext接口
- ServletConfig和ServletContext接口
- ServletConfig 接口和ServletContext 接口
- ServletConfig 接口和ServletContext 接口
- ServletContext和servletconfig区别
- ServletContext和ServletConfig分析
- ServletContext,ServletConfig和Sesion
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- (24)ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- ServletConfig和ServletContext
- BGP 配置
- python学习-字符串操作
- hdu BFS 2952
- Outlook2013/2016中的Gmail设置
- hdu 2795 billboard(线段树)
- ServletConfig和ServletContext接口
- Ubuntu16.04下python+PyCharm开发环境的搭建
- [dfs 离线] Hillan模拟赛 C.可持久化的书橱
- ecshop数据库表6(ecs_admin_user)管理表
- Caffe中crop_layer层的理解和使用
- KMP循环节
- java.io.IOException: Too many open files
- [人工智能]人工智能、机器学习和深度学习三者之间的关系
- 用友uap开发报错:流程平台缓存中不存在该单据或交易类型=xxx