web.xml详解

作者: MVBin | 来源:发表于2017-05-23 11:17 被阅读37次

filter配置多个url-pattern的正确方式

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

classpath与classpath*的区别

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/spring/*.xml</param-value>
</context-param>

这种classpath配置是指只加载本地classpath路径下的spring文件夹中的以.xml结尾的文件。

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/spring/*.xml</param-value>
</context-param>

这种classpath*配置是指不仅加载本地classpath路径下的,而且也加载jar文件下的classpath路径下的spring文件夹中的以.xml结尾的文件。

配置load-on-startup的作用

在web.xml中配置servlet时有时需要配置load-on-startup这个属性,其作用是指在web容器启动时是否就加载该servlet,其值需为整数。当<load-on-startup></load-on-startup>中的值大于等于0时,表示在容器启动时就加载,值越小,加载优先级越高;当小于0或者没有值时,表示在用到此servlet时才加载,不在启动时加载。

相关文章

  • web.xml 的加载顺序

    web.xml 的加载顺序是: web.xml文件详解 Web.xml常用元素

  • web.xml详解

    web.xml详解 一、web.xml简介 在java工程中,web.xml用来初始化工程配置信息,比如说welc...

  • web.xml文件详解

    web.xml文件详解 前言:一般的web工程中都会用到web.xml,web.xml主要用来配置,可以方便的开发...

  • Web.xml配置说明以及加载过程

    1. web.xml配置详解

  • web.xml详解

    filter配置多个url-pattern的正确方式 classpath与classpath*的区别 这种clas...

  • web.xml详解

  • web.xml详解

  • web.xml详解备忘

    学了一段时间的Java Web,很早也知道tomcat,但是每每开始进行开发时,总是遇到很多陌生名词和概念。不得已...

  • web.xml文件详解

    前言:一般的web工程中都会用到web.xml,web.xml主要用来配置,可以方便的开发web工程。web.xm...

  • web.xml配置详解

    1. XML文档有效性检查 这段代码指定文件类型定义(DTD),可以通过它检查XML文档的有效性。下面显示的

网友评论

    本文标题: web.xml详解

    本文链接:https://www.haomeiwen.com/subject/xuvwxxtx.html