使用maven创建web工程并自动部署到Tomcat中
1、创建maven web工程,eclipse中:File--->new--->others--->maven--->maven project

2、点击Next,选择工作空间(也可以使用默认的)

3、点击Next,选择Java web 工程的模版

4、填写相关信息,点击finish

5、Jsp程序报错主要原因是因为没有导入Server的包

6、工程右击--->Build Path --->Configure Build path弹出的框点击Add Library又弹出的框选择Server Runtime-->选择部署的Tomcat服务器(如果没有Tomcat服务器先去配置Tomcat服务器)

7、自动部署到tomcat,下面在web项目中的pom.xml中定义,build如下代码copy到pom.xml就可以了:
<build>
<finalName>Hello</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.6.4</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<home>E:\apache-tomcat-8.0.36-windows-x64\caf-tomcat-8.0.36</home>
</container>
<configuration>
<type>existing</type>
<home>E:\apache-tomcat-8.0.36-windows-x64\caf-tomcat-8.0.36</home>
</configuration>
</configuration>
<executions>
<execution>
<id>cargo-run</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>