项目结构:
Maven工程没有Tomcat环境也能运行web工程:(pom.xml中)
1, 配置tomcat-maven插件
<build>
<finalName>babasport</finalName>
<!-- 添加tomcat插件,eclipse不用再配置tomcat运行环境.
Run As-Maven build...-clean package 启动web页面
-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<!-- 本地jdk版本 -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
<version>3.0-r1756463</version>
<!-- 在package阶段启动web容器 -->
<executions>
<execution>
<!-- 打包阶段 -->
<phase>package</phase>
<!-- 运行目标 -->
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
2, 配置jsp ,servlet 等依赖
<!-- 配置jsp依赖 -->
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jsptags/pager-taglib -->
<dependency>
<groupId>jsptags</groupId>
<artifactId>pager-taglib</artifactId>
<version>2.0</version>
<!-- -->
<scope>provided</scope>
</dependency>
1
<!-- 配置jsp依赖 -->
2
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
3
<dependency>
4
<groupId>javax.servlet.jsp</groupId>
5
<artifactId>jsp-api</artifactId>
6
<version>2.2</version>
7
<scope>provided</scope>
8
</dependency>
9
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
10
<dependency>
11
<groupId>javax.servlet</groupId>
12
<artifactId>jstl</artifactId>
13
<version>1.2</version>
14
</dependency>
15
<!-- https://mvnrepository.com/artifact/jsptags/pager-taglib -->
16
<dependency>
17
<groupId>jsptags</groupId>
18
<artifactId>pager-taglib</artifactId>
19
<version>2.0</version>
20
<!-- -->
21
<scope>provided</scope>
22
</dependency>