通过web.xml传递初始参数
来源:互联网 发布:nginx实现session共享 编辑:程序博客网 时间:2024/06/06 23:17
一、servlet初始化参数的传递:
第一步:web.xml中:
<servlet>
<servlet-name>SearchItemServlet</servlet-name>
<servlet-class>com.bjpowernode.drp.basedata.web.SearchItemServlet</servlet-class>
<!-- 在相应的<servlet>标签中加入下面的标签和参数 -->
<init-param>
<param-name>page-size</param-name>
<param-value>3</param-value>
</init-param>
</servlet>
第二步:servlet中:
通过如下代码得到web.xml中<servlet>标签里<init-param>中的<param-name>对应的<param-value>里的值
int pageSize = Integer.parseInt(this.getServletConfig().getInitParameter("page-size"));
该操作只对web.xml中相应的servlet起作用
二、application作用范围的参数传递
第一步:web.xml中:
<context-param>
<param-name>page-size</param-name>
<param-value>2</param-value>
</context-param>
第二步:servlet中:
int pageSize = Integer.parseInt(this.getServletContext().getInitParameter("page-size"));
该操作对整个application起作用
第一步:web.xml中:
<servlet>
<servlet-name>SearchItemServlet</servlet-name>
<servlet-class>com.bjpowernode.drp.basedata.web.SearchItemServlet</servlet-class>
<!-- 在相应的<servlet>标签中加入下面的标签和参数 -->
<init-param>
<param-name>page-size</param-name>
<param-value>3</param-value>
</init-param>
</servlet>
第二步:servlet中:
通过如下代码得到web.xml中<servlet>标签里<init-param>中的<param-name>对应的<param-value>里的值
int pageSize = Integer.parseInt(this.getServletConfig().getInitParameter("page-size"));
该操作只对web.xml中相应的servlet起作用
二、application作用范围的参数传递
第一步:web.xml中:
<context-param>
<param-name>page-size</param-name>
<param-value>2</param-value>
</context-param>
第二步:servlet中:
int pageSize = Integer.parseInt(this.getServletContext().getInitParameter("page-size"));
该操作对整个application起作用
- 通过web.xml传递初始参数
- 通过web.xml传递初始参数
- 3.使用资源注射(@Resource)读取web.xml初始参数
- 通过网页传递参数[WEB学习示例]
- 用 WebDAV 通过 Web 传递 XML 数据
- 初始的web.xml
- 在Servlet和JSP中访问web.xml设置的初始参数
- 通过Intent传递参数
- javaEE之------Servlet通过web.xml传参数(生命周期)
- web传递中文参数
- 如何让Tomcat自动Load被修改过的类 servlet如何读取web.xml中的初始参数
- Servlet(3)ServletConfig接口的介绍(获取web.xml中某个Servlet中的初始配置参数)
- 通过地址栏传递参数.通过url传递参数
- Struts2通过实体传递参数
- ajax通过post传递参数
- ClickOnce 通过URL传递参数
- UVM::通过cmdline传递参数
- HttpClient通过HttpPost传递参数
- Get the distributed keys of Greenplum by SQL query
- 系统未正确安装新的设备驱动程序后 开机总是出现“欢迎使用找到新硬件向导”
- jfreechar map标签输出问题
- 一致性hash算法( consistent hashing )
- 数据库设计范式
- 通过web.xml传递初始参数
- 一名计算机讲师给计算机同学的几点建议
- android中调用相册里面的图片并返回
- 【Android】画图之Matrix
- GPU软件体系
- win7 x64 sp1系统在 VS 2010旗舰版下配置OpenCV 2.3.1
- 技术不好~紧张
- android 轮循的处理 Handler
- JVM terminated.Exit code = -1的错