zoukankan      html  css  js  c++  java
  • 对javaweb项目中web.xml重用配置的理解(个人学习小结)

    <!-- 所有的总结描述性与语言都在注释中 -->
    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>这里是项目的说明信息,可以不写</display-name> <welcome-file-list> <!-- 这里是欢迎页面的设置 --> <welcome-file>index.html</welcome-file> </welcome-file-list> <!-- servlet 的基本设置 --> <servlet> <!-- servlet的名字 --> <servlet-name>LoginServlet</servlet-name> <!-- servlet对应的java文件 --> <servlet-class>com.review.LoginServlet</servlet-class> <!-- 是否设置为异步处理 --> <async-supported>true</async-supported> </servlet> <servlet-mapping> <!-- 想要配置映射路径的 servlet 的名字 --> <servlet-name>LoginServlet</servlet-name> <!-- 该servlet 下的一种映射 --> <url-pattern>/LoginSerlet</url-pattern> </servlet-mapping> <!-- 过滤器配置 --> <filter> <!-- 过滤器的名字 --> <filter-name>LoginFilter</filter-name> <!-- 过滤器对应的类 --> <filter-class>com.reviw.LoginFilter</filter-class> <!-- 是否设置为异步处理 --> <async-supported>true</async-supported> <init-param> <!-- 参数名 --> <param-name>charset</param-name> <!-- 参数值 --> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <!-- 需要进行配置的过滤器名 --> <filter-name>LoginFilter</filter-name> <!-- 需要过滤的请求 --> <url-pattern>*.jsp</url-pattern> <!-- 处理类型,,当前是默认值,还有 forword included error async--> <dispatcher>REQUEST</dispatcher> </filter-mapping> <listener> <listener-class>com.review.Listener</listener-class> </listener> <error-page> <error-code>404</error-code> <location>/notfund.jsp</location> </error-page> <error-page> <exception-type>java.lang.ArrayIndexOutOfBoundsException</exception-type> <location>/exception.jsp</location> </error-page> </web-app>

    其中取参数:

    @WebServlet("/GetPara")
    public class GetPara extends HttpServlet implements Filter  {
        private static final long serialVersionUID = 1L;
         
        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
            // TODO Auto-generated method stub
            String paraValue=filterConfig.getInitParameter("charset");
        }
    /*略去需要覆写的其它方法*/
    
    }
  • 相关阅读:
    802.11标准及无线网运行模式
    linux中top命令使用及查看tcp连接
    DNS信息收集命令nslookup
    Openvas安装
    nc高级应用
    poj 1411 Calling Extraterrestrial Intelligence Again(超时)
    poj 1046 Color Me Less
    1215 迷宫
    2666 Accept Ratio(打表AC)
    2021 中庸之道
  • 原文地址:https://www.cnblogs.com/ClimberZheng/p/10832449.html
Copyright © 2011-2022 走看看