web.xml文件配置说明

xiaoxiao2026-10-04  11

以下是web.xml文件配置的详细说明<?xml version="1.0" encoding="UTF-8"?><web-app ......><servlet> //配置一个实例名 <servlet-name>xxx</servlet-name> //设定该servlet的实例名 <servlet-class>xxx</servlet-class> //设定该servlet的类名 <int-param> //设定该Servlet的初始化参数 <param-name>xxx</param-name> //设定参数名 <param-value>xxx</param-value> //设定参数值 </int-param> <load-on-startup>0</load-on-startup> //设置servlet在WEB应用启动时被加载的次序,数值越小 //就越先被加载,如果为负或者没有设置就在再次访问该Servlet时加载。</servlet><servlet-mapping> //配置一个Servlet映射 <servlet-name>xxx</servlet-name> //引用前面设定的Servlet实例名 <url-pattern>/xxx</url-pattern> //设定访问该Servlet的URL</servlet-mapping><filter> //配置一个过滤器 <filter-name>xxx</filter-name> //设定该过滤器的实例名 <filter-class>xxx</filter-class> //设定该过滤器的类名 <init-param> //设定该过滤器的初始化参数 <param-name>xxx</param-name> //设定参数名 <param-value>xxx</param-value> //设定参数值 </init-param></filter><filter-mapping> //配置一个过滤器映射 <filter-name>xxx</filter-name> //引用前面设定的过滤器实例名<url-pattern>/*/</url-parttern> //设置要过滤的URL</filter-mapping><listener> //配置一个监听器 <listener-class>xxx</listener-class> //设定该监听器的类名</listener><jsp-config> //设置JSP的配置信息<taglib> //定位一个标签库 <taglib-uri>/xx</taglib-uri> //设定标签库的引用URL <taglib-location>xxx</taglib-locathion> //设定标签库文件的存放路径</tablib></jsp-config><welcome-file-list> //设置欢迎文件菜单 <welcome-file>xxx</welcome-file> //设置一个具体的欢迎文件名</welcome-file-list><error-page> //设置一个处理错误的页面 <error-code>xxx</error-code> //设定一个具体的错误代码,如404 <location>/xx</location> //设定一个处理错误的页面</error-page><session-config> //设置Session的会话闲置时间 <session-timeout>xxx</session-timeout>设定一个具体的分钟数,如60</seeion-config></web-app>注:其中servlet、servlet-mapping、filter、filter-mapping、init-param、listener、taglib、welcome-file、error-page等元素可以出现一次或多次,其他的最多只能出现一次!
转载请注明原文地址: https://www.6miu.com/read-5053596.html

最新回复(0)