在web.xml中配置一个servlet
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><display-name>student</display-name><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list><servlet><servlet-name>test</servlet-name><servlet-class>com.test.Test</servlet-class><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>test</servlet-name><url-pattern>/test</url-pattern></servlet-mapping></web-app><servlet-name>test</servlet-name>servlet的名称
<servlet-class>com.test.Test</servlet-class>servlet的类全称(包名.类名)
<load-on-startup>1</load-on-startup>是否在服务器启动时就加载,如果不用在服务器启动时就加载可以去掉此项
<url-pattern>/test</url-pattern>servlet的访问路径
页:
[1]