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

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

问题描述

我想使用Eclipse编写Java servlet,并计划使用Tomcat进行部署。我想我可以使用Eclipse捆绑的Ant来构建项目。我有标准的Eclipse IDE。在Eclipse中进行Servlet开发有什么选择?我需要做什么改变到Eclipse?我需要安装一个插件吗?

解决方案

你需要安装一个插件,有一个免费的Eclipse基金会称为 Web工具平台。它具有您需要的所有开发功能。



您可以获取

要创建并运行您的第一个servlet,请执行以下操作:


  1. 新建...项目...动态Web项目。

  2. 右键单击项目...新Servlet。 / li>
  3. doGet()方法中编写一些代码。

  4. 查找Java EE透视图,通常是底部的选项卡之一。

  5. 右键单击并选择新的服务器。

  6. 选择Tomcat XX和a向导将指向您找到安装。

  7. 右键单击刚刚创建的服务器,然后选择添加和删除... 并添加创建的Web项目。 / li>
  8. 右键单击您的servlet,然后选择运行>在服务器上运行...

它为你您可以使用蚂蚁来构建这里,如果这是你想要的,但是eclipse实际上会进行构建并自动将更改部署到服务器上。使用Tomcat,您可能必须每次重新启动它,具体取决于更改。


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?

解决方案

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.

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

To create and run your first 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...

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天全站免登陆