导入
设置 Web 应用程序
学习如何创建一个使用 Tomcat 服务器运行的简单 Web 应用程序。
1 2<dependencies> 3 <dependency> 4 <groupId>javax</groupId> 5 <artifactId>javaee-web-api</artifactId> 6 <version>6.0</version> 7 <scope>provided</scope> 8 </dependency> 9</dependencies>
1 2<build> 3 <pluginManagement> 4 <plugins> 5 <plugin> 6 <groupId>org.apache.maven.plugins</groupId> 7 <artifactId>maven-compiler-plugin</artifactId> 8 <version>3.2</version> 9 <configuration> 10 <verbose>true</verbose> 11 <source>1.8</source> 12 <target>1.8</target> 13 <showWarnings>true</showWarnings> 14 </configuration> 15 </plugin> 16 <plugin> 17 <groupId>org.apache.tomcat.maven</groupId> 18 <artifactId>tomcat7-maven-plugin</artifactId> 19 <version>2.2</version> 20 <configuration> 21 <path>/</path> 22 <contextReloadable>true</contextReloadable> 23 </configuration> 24 </plugin> 25 </plugins> 26 </pluginManagement> 27</build>
1 2<welcome-file-list> 3 <welcome-file>player.do</welcome-file> 4</welcome-file-list>
...
Client request handled by web.xml
1 2<web-app xmlns="http://java.sun.com/xml/ns/javaee" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 5 version="3.0"> 6 7 <display-name>Tennis Player DB</display-name> 8 9 <welcome-file-list> 10 <welcome-file>player.do</welcome-file> 11 </welcome-file-list> 12 13</web-app>