eclipse中新建一个web项目 | 您所在的位置:网站首页 › 在eclipse中创建web项目 › eclipse中新建一个web项目 |
前提:已在eclipse中配置过tomcat 这里:eclipse+jdk8+tomcat9 jdk+eclipse配置安装:https://blog.csdn.net/qq_35634418/article/details/79986985 tomcat9安装:https://blog.csdn.net/qq_35634418/article/details/89059737 eclipse中配置tomcat:https://blog.csdn.net/qq_35634418/article/details/89059927
打开eclipse File-->new-->other-->web--Dynamic Web Project 点击next,然后输入web项目名,以HelloWorld为例 然后点击next,再点击next(若直接点击finish,就需要自己建web.xml文件) 将Generate web.xml deployment descriptor勾选 点击finish
设置window--> show view--Servers 然后点击下方蓝字:No servers are available. Click this link to create a new server...添加tomcat服务器 选择以配置安装的tomcat,本为tomcatv9.0 点击next,然后将刚刚新建的web项目添加到右侧(点击HelloWorld-->点击Add> ) 然后点击finish(web项目想要运行,必须先将其服务器中,即右击servers中tomcat,选择add and remove)
右击HelloWorld项目中WebContent文件夹,新建一个jsp文件,命名为index.jsp 点击finish 然后打开index.jsp 在body标签中输入一句话 例: 这是一个web项目 然后保存
在下方Servers栏中右击显示的tomcat,如Tomcat v9.0 Server at localhost 然后点击start启动tomcat服务器 Console中不显示错误信息,证明tomcat成功启动 然后点击上方run按钮,运行index.jsp 成功显示“这是一个web项目” -----------------完成---------------- 注意:若点击运行run,显示tomcat错误,什么端口已被占用 右击Servers中tomcat,然后点击restart重启tomcat试试,多试几次 如果仍然不行,servers中tomcat删了重新添加试试,或是看看tomcat配置是否出现问题什么的 当然,如果你eclipse版本用的不对,window-->preferences-->server中server都找不到,虽然能装回server,这里就不说了
真要看不懂,推荐这个文章https://blog.csdn.net/xiaota00/article/details/78429924详细清楚
|
CopyRight 2018-2019 实验室设备网 版权所有 |