以获取Filer元素里设置的参数为例

先在web.xml文件中配置如下

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<filter>
<!--定义过滤器-->
<filter-name>filter</filter-name>
<!--这个自定义类 在项目中的某个包中-->
<filter-class >com.ou.book.filter.UrlFilter</filter-class>
<!--设置默认的参数-->
<init-param>
<param-name>value</param-name>
<param-value>nihao,wula,haha,heihei</param-value>
</init-param>
</filter>
<filter-mapping>
<!--使用上面定义的filter过滤器拦截-->
<filter-name>filter</filter-name>
<!-- /* -> 拦截所有请求 -->
<url-pattern>/*</url-pattern>
</filter-mapping> </web-app>

然后再用自定义的UrlFilter类读取出设置的默认参数。

实现javax.servlet 中的Filter的接口

获取的结果:

通过字符窜的分割函数拿出多个值,然后就进行你的操作了。

读取web.xml中设置的参数的更多相关文章

  1. servlet中用注解的方式读取web.xml中的配置信息

    在学习servletContext的时候,我们知道了可以在web.xml中通过<context-param>标签来定义全局的属性(所有servlet都能读取的信息),并在servlet中通 ...

  2. lisener在web.xml中设置

    /* * servlet监听器开发步骤: * 1.写一个类实现XXXListener接口(6个=3个容器+3个对容器中属性进行操作) * 2.在web.xml中配置<listener> - ...

  3. Web.xml中设置Servlet和Filter时的url-pattern匹配规则

    一.servlet容器对url的匹配过程: 当一个请求发送到servlet容器的时候,容器先会将请求的url减去当前应用上下文的路径作为servlet的映射url,比如我访问的是http://loca ...

  4. Asp.Net中的获取Web.config中设置的参数!(前后台的代码示例)

    一.Web.config中设置代码     <appSettings>         <add key="deleted" value="1" ...

  5. application 从web.xml中获取初始化参数

    <span style="font-size:24px;"> </span> 1.web.xml中的配置部分 <context-param>   ...

  6. 在web.xml中设置全局编码

    在web.xml中配置 <filter> <filter-name>characterFilter</filter-name> <filter-class&g ...

  7. web.xml中servlet初始化参数的设置

    <context-param><param-name>param1</param-name><param-value>value1</param- ...

  8. websphere中的会话超时设置 和 web应用中web.xml中session-timeout关系

    Tomcat默认的会话的超时时间设置 设置Tomcat session有效期的三种方式有: 1.在tomcat/conf/web.xml中修改session-timeout的值,该设置是TOMCAT全 ...

  9. (转)web.xml中的contextConfigLocation在spring中的作用

    (转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...

随机推荐

  1. 【ABAP系列】【第六篇】SAP ABAP7.50 之隐式增强

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列][第六篇]SAP ABAP7.5 ...

  2. script学习,如何用linux监控你的同事?

    环境:CentOS7 一.为什么要学习script命令 当你在终端或控制台上工作时,你想记录下自己做了些什么吗?当你跟一些Linux管理员同时在系统上干活,你想知道别人干了什么吗?当你让别人远程到你的 ...

  3. 【机器学习实践】Jupyter Notebook安装 侧边导航栏功能 操作及其他常用扩展功能介绍

    安装过程:  1. 首先我们引入jupyter_contrib_nbextension这个第三方库. 2. 在Anaconda Promot中输入命令: pip install jupyter_con ...

  4. 【Linux开发】linux设备驱动归纳总结(十一):写个简单的看门狗驱动

    linux设备驱动归纳总结(十一):写个简单的看门狗驱动 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  5. AKKA文档2.1(java版)——什么是AKKA?

    可扩展的实时事务处理 我们相信编写并发.容错.可扩展的应用相当的困难.盖因大多数时候我们一直在使用错误的工具和错误的抽象等级.AKKA就是为了改变这一切的.我们利用角色模型提升了抽象等级,并且提供了一 ...

  6. SpringSecurity 配置

    SpringSecurity+JWT https://www.jianshu.com/p/5b9f1f4de88d https://blog.csdn.net/qq_35494808/article/ ...

  7. unsigned char 与unsigned long互换

    unsigned long UCharToULong(unsigned char * pucVar ){unsigned long ulTemp=0;ulTemp=(unsigned long)(*p ...

  8. jvm 调优工具 i

    https://blog.csdn.net/wait_notify/article/details/70268194 https://blog.csdn.net/a718515028/article/ ...

  9. H.Holy Grail ( floyd )(The Preliminary Contest for ICPC Asia Nanjing 2019)

    题意: 给出一个有向图,再给出6条原来不存在的路径,让你在这6条路径上添加一个最小的数,使图不存在负环. 思路: 直接6遍 floyd 输出就行了. #include <bits/stdc++. ...

  10. Thinkphp6框架学习:($this->error()undefined)Call to undefined method app\index\controller\Admin::error()

    最近在使用Thinkphp6框架的时候,想做一个初始化来验证登录状态. 当没有Session::get(‘adminUid’)的时候就应该跳转到admin\adminLogin的方法中,和以前Tp5的 ...