eclipse+tomcat部署WEB项目
转载:https://www.jianshu.com/p/14eca79b1dd5
1.下载JDK并且配置环境变量,我之前就配置好了,这里就不详细赘述了,步骤参照如下:https://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html
2.下载eclipse,下载地址:https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2019-03/R/eclipse-inst-win64.exe

3.下载tomcat,下载地址为:https://tomcat.apache.org/download-90.cgi

下载完了后,解压缩,我是解压到D盘下面的

4.新建一个动态的web工程

输入项目的名字,选择Next

继续Next

勾选Generate web.xml deployment descriptor,点击finish,这样我们就生成了一个名字为Hello的动态Web工程,如下图:


5.配置tomcat
(1)点击Servers中的链接,添加tomcat

(2)选中Tomcat v9.0 Server,继续Next

(3)直接点击Finish,暂时不添加项目(这个点比较重要,如果添加了项目后就不能更改tomcat的配置了)

(4)双击Servers中的tomcat

(5)更改Server Locations和Publishing中的内容

(6)更改Ports中的端口号,修改为8888(自己定)

记得按ctrl+s保存后关掉tomcat的配置页面
6.进行测试
在WebContent下面新建一个index.jsp文件

新建完了,会发现页面报错

查找资料后,处理问题步骤如下:
(1)在出现此错误的项目Hello上单击鼠标右键-->Build Path-->Configure Build Path

(2)选中Libraries-->Add Library

(3)选中Server Runtime,点击Next

(4)选中Tomcat 9.0,点击Finish

(5)选中Order and Export,勾选其中三项,点击Apply and Close

这样项目的报错问题就解决了
在index.jsp中输入内容:你好呀!!保存

然后在Servers中选中Tomcat 9.0,右击,选择Add and Remove

选中Hello项目,点击Add ,最后点击finish

我们会看到Hello项目被添加到Tomcat下面了

点击Servers中的Tomcat 9.0,右击,选择clean,再右击,选择start


如果看到控制台没有报错,就证明ok了
打开浏览器,输入http://localhost:8888/Hello/index.jsp ,可以看到页面返回index.jsp中的内容

因为默认访问的是WebContent下面的index.jsp,所以我们输入http://localhost:8888/Hello/ ,也是返回的是index.jsp中的内容

作者:测试zhang
链接:https://www.jianshu.com/p/14eca79b1dd5
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。