tomcat8.5web.xml
时间: 2023-10-11 22:06:27 浏览: 63
在Tomcat 8.5中,web.xml是用于配置Web应用程序的重要文件之一。下面是一些常见的配置项:
1. 欢迎页配置:
```
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
```
这段配置指定了当用户访问Web应用程序根目录时要显示的默认欢迎页。
2. 初始化参数配置:
你可以在web.xml中配置应用程序的初始化参数。这些参数可以在Servlet中使用。
```
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.example.TestServlet</servlet-class>
<init-param>
<param-name>param1</param-name>
<param-value>value1</param-value>
</init-param>
<init-param>
<param-name>param2</param-name>
<param-value>value2</param-value>
</init-param>
</servlet>
```
这个例子中,TestServlet是一个实现了HttpServlet的类,通过init-param配置了两个初始化参数。
3. 错误页配置:
```
<error-page>
<location>/error.jsp</location>
<error-code>500</error-code>
<exception-type>java.lang.Exception</exception-type>
</error-page>
```
这段配置指定了当发生500错误,并且异常类型为java.lang.Exception时,要显示的错误页面为/error.jsp。
通过这些配置项,你可以自定义Tomcat 8.5中的web.xml文件,以满足你的应用程序的需求。