第一个javaWeb项目

创建第一个web项目
第一步:
在project explorer右键新建>>>dynamic web project>>>输入项目名字>>>next>>>next>>>勾选generate web.xml deployment descriptor来创建一个web.xml配置文件>>>finish,到此第一个web项目建立起来。

第二步:
选中web项目右键新建>>>jsp file,命名为index. jsp,若jsp项目里面报错:The superclass javax .servlet.http.HttpServlet was not found on the Java Build Path
请看这篇博客
https://www.cnblogs.com/achengmu/p/882457.html

到这里第一个web项目创建成功。
在这里插入图片描述

创建tomcat服务器
切换到servers窗口>>>右键server>>>apache>>>选择自己安装的tomcat>>>finish即可。
在这里插入图片描述
要让tomcat服务器加载web项目
切换到servers窗口>>>点击tomcat服务器>>>右键add and remove>>>将左边avaiable下面的项目放到右边configured即可。相反将右边的configured下面的项目放到左边available下面就是没有加载。
在这里插入图片描述导入servlet-api.jar包
如果是按照上面的步骤来创建项目的,就不需要导入此包,因为web项目里面加载到了tomcat服务器,而tomcat服务器里面有相关的servlet包,因此就不需要导入servlet-api等包啦。

猜你喜欢

转载自blog.csdn.net/weixin_44421869/article/details/103099687