web.xml

Posted wuchao0508

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web.xml相关的知识,希望对你有一定的参考价值。

在Tomcat/conf下有一个web.xml文件,当Tomcat中所有web应用实例化时都会读取该配置文件,然后读取每个web应用自己的配置文件(/WEB-INF/web.xml)。

conf/web.xml作出以下配置:

//处理未映射到其他servlet的请求
    <servlet>
        <servlet-name>default</servlet-name>
        <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>0</param-value>
        </init-param>
        <init-param>
            <param-name>listings</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
//jsp页面编译和执行servlet
    <servlet>
        <servlet-name>jsp</servlet-name>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
            <param-name>fork</param-name>
            <param-value>false</param-value>
        </init-param>
        <init-param>
            <param-name>xpoweredBy</param-name>
            <param-value>false</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
    </servlet>
//映射关系
    <!-- The mapping for the default servlet -->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- The mappings for the JSP servlet -->
    <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>

//会话设置
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
//MIME类型映射
    <mime-mapping>
        <extension>123</extension>
        <mime-type>application/vnd.lotus-1-2-3</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>3dml</extension>
        <mime-type>text/vnd.in3d.3dml</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>3ds</extension>
        <mime-type>image/x-3ds</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>3g2</extension>
        <mime-type>video/3gpp2</mime-type>
    </mime-mapping>
...
...
...

 

以上是关于web.xml的主要内容,如果未能解决你的问题,请参考以下文章

web.xml详解

web.xml 文件配置01

web.xml

web.xml

web.xml

web.xml的作用