web-xml详解

来源:互联网 发布:daz3d知乎 编辑:程序博客网 时间:2024/05/22 09:42

web.xml详解

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时才加载,不在启动时加载。

0 0
原创粉丝点击