您如何使用 Eclipse 开发 Java Servlet? [英] How do you develop Java Servlets using Eclipse?

查看:23
本文介绍了您如何使用 Eclipse 开发 Java Servlet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Eclipse 编写 Java servlet,并计划使用 Tomcat 部署它们.我想我可以使用与 Eclipse 捆绑在一起的 Ant 构建项目.我有标准的 Eclipse IDE.在 Eclipse 中进行 Servlet 开发有哪些选择?我需要对 Eclipse 进行哪些更改?我需要安装插件吗?

I would like to program Java servlets using Eclipse and I plan on deploying them using Tomcat. I think I can build the projects using Ant which is bundled with Eclipse. I have the standard Eclipse IDE. What options do I have for doing Servlet development in Eclipse? What changes do I need to make to Eclipse? Do I need to install a plug-in?

推荐答案

你需要安装一个插件,eclipse 基金会有一个免费的,叫做 网络工具平台.它具有您需要的所有开发功能.

You need to install a plugin, There is a free one from the eclipse foundation called the Web Tools Platform. It has all the development functionality that you'll need.

您可以获得 Java EE 版 eclipse 并预先安装它.

You can get the Java EE Edition of eclipse with has it pre-installed.

要创建并运行您的第一个 servlet:

To create and run your first servlet:

  1. 新建...项目...动态网络项目.
  2. 右键单击项目...新建 Servlet.
  3. doGet() 方法中编写一些代码.
  4. 在 Java EE 透视图中找到服务器视图,它通常是底部的选项卡之一.
  5. 右键单击那里并选择新服务器.
  6. 选择 Tomcat X.X,向导会指引您找到安装.
  7. 右键单击您刚刚创建的服务器并选择添加和删除...,然后添加您创建的 Web 项目.
  8. 右键单击您的 servlet 并选择运行 > 在服务器上运行...
  1. New... Project... Dynamic Web Project.
  2. Right click the project... New Servlet.
  3. Write some code in the doGet() method.
  4. Find the servers view in the Java EE perspective, it's usually one of the tabs at the bottom.
  5. Right click in there and select new Server.
  6. Select Tomcat X.X and a wizard will point you to finding the installation.
  7. Right click the server you just created and select Add and Remove... and add your created web project.
  8. Right click your servlet and select Run > Run on Server...

那应该对你有用.如果您愿意,您可以使用 ant 在这里构建,但 eclipse 将实际执行构建并自动将更改部署到服务器.使用 Tomcat,您可能需要不时地重新启动它,具体取决于更改.

That should do it for you. You can use ant to build here if that's what you'd like but eclipse will actually do the build and automatically deploy the changes to the server. With Tomcat you might have to restart it every now and again depending on the change.

这篇关于您如何使用 Eclipse 开发 Java Servlet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆