web开发环境搭建 eclipse

下载jdk、eclipse EE版本。
下载tomcat tomcat具体配置百度

运行eclipse EE

2.2 设置 Tomcat
在 Eclipse 中,点击菜单栏 Window->Preferences , 点击 Server / Runtime Environments :

点击 “Add”按钮, 新建一个服务器。我们之前安装了 Tomcat 9.0, 所以这里也选择它。

点击”Next”进入下一步。

在Tomcat installation directory下面的文本框中输入tomcat的安装目录,点击”finish”完成配置。

2.3 设置默认的字符集
在eclipse中,会默认使用当前操作系统的字符集,一般会是GBK。然而我们开发web应用程序时,一般使用UTF-8。所以需要设置一下默认的字符集。
在 Eclipse 中,点击菜单栏 Window->Preferences , 点击 General / Workspace :

在 Text file encoding 区域选择  Other : UTF-8 。 这样子以后我们新建项目时,会默认使用 UTF-8 字符编码。

2.4 设置 Build Path

在开发Web应用程序时,需要用到 Tomcat ,我们要将 Tomcat / lib 加入编译路径中。否则你会在建立 jsp 时,出现如下错误:

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

在 Eclipse 中,点击菜单栏 Window->Preferences , 点击 Java / Build Path / Classpath Variables :

点击“New”新建名为“Tomcat Server”的变量,将Path设置为tomcat的安装位置中的lib目录(如上图所示),点击“OK”按钮。

接下来,添加 User Libraries。点击 Java / Build Path / User Libraries :

点击“New…”按钮,新建名为 Tomcat Server 的User Libraries。然后点击“Add External JARs…”按钮,将我们安装并使用的tomcal / lib 下的所有 jar 选中(Ctrl + A)并确定。完成后如上图所示。

点击“OK”完成设置。

 

2.5 Hello World

每一次搭建完开发环境,写一个 “hello world” 并成功的显示出来, 心情会自然变得舒畅。

在 Eclipse Java EE 中, 在左边的 Project Explorer 的空白区域点击鼠标右键, 然后点击 “New->Dynamic Web Project” :

点击“Finish”完成。

然后在WebContent上右键,在右键菜单中点击“New->JSP File”,新建一个 Index.jsp 页面。

 

在标签内输入 hello world
选择“Run As”–>>Run on Server–>>打开“Run on Server”窗口,选中Tomcat 8.0服务器,单击“Finish”就可以运行项目了。这里写图片描述
大功告成。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值