netbeans ide_使用Netbeans IDE创建第一个Servlet应用程序

netbeans ide

In the last lesson we created our first Servlet Application but without using any IDE. An IDE is Integrated Development Environment, and it makes creating applications a lot easier. We will learn how to create Servlet applications on NetBeans IDE and Eclipse IDE. Then you can decide which one, you want to use.

在上一课中,我们创建了第一个Servlet Application,但没有使用任何IDE。 IDE是集成开发环境,它使创建应用程序变得容易得多。 我们将学习如何在NetBeans IDE和Eclipse IDE上创建Servlet应用程序。 然后,您可以决定要使用哪一个。

Using Intregrated Development Enviroment(IDE) is the easiest way to create Servlet Applications. An IDE is a software application that provides facilities to computer programmers for software development. Eclipse, MyEcplise, Netbeans are example of some popular Java IDE.

使用Intregrated Development Enviroment(IDE)是创建Servlet应用程序的最简单方法。 IDE是一种软件应用程序,为计算机程序员提供用于软件开发的工具。 EclipseMyEcpliseNetbeans是一些流行的Java IDE的示例。

在Netbeans IDE中创建Servlet应用程序的步骤 (Steps to Create Servlet Application in Netbeans IDE)

To create a servlet application in Netbeans IDE, you will need to follow the following (simple) steps :

要在Netbeans IDE中创建servlet应用程序,您将需要执行以下(简单的)步骤:

  1. Open Netbeans IDE, Select File -> New Project

    打开Netbeans IDE,选择File- > New Project

    steps to create servlet application in netbeans
  2. Select Java Web -> Web Application, then click on Next,

    选择Java Web- > Web Application ,然后单击Next,

    steps to create servlet application in netbeans
  3. Give a name to your project and click on Next,

    为您的项目命名,然后单击“下一步”,

    steps to create servlet application in netbeans
  4. and then, Click Finish

    然后,单击完成

    steps to create servlet application in netbeans
  5. The complete directory structure required for the Servlet Application will be created automatically by the IDE.

    Servlet应用程序所需的完整目录结构将由IDE自动创建。

    steps to create servlet application in netbeans
  6. To create a Servlet, open Source Package, right click on default packages -> New -> Servlet.

    要创建Servlet,请打开Source Package ,右键单击默认包 -> New- > Servlet

    steps to create servlet application in netbeans
  7. Give a Name to your Servlet class file,

    给您的Servlet类文件命名,

    steps to create servlet application in netbeans
    steps to create servlet application in netbeans
  8. Now, your Servlet class is ready, and you just need to change the method definitions and you will good to go.

    现在,您的Servlet类已经准备好了,您只需要更改方法定义就可以了。

    steps to create servlet application in netbeans
  9. Write some code inside your Servlet class.

    在Servlet类中编写一些代码。

    steps to create servlet application in netbeans
  10. Create an HTML file, right click on Web Pages -> New -> HTML

    创建一个HTML文件,右键单击Web页面 -> New- > HTML

    steps to create servlet application in netbeans
  11. Give it a name. We recommend you to name it index, because browser will always pick up the index.html file automatically from a directory. Index file is read as the first page of the web application.

    给它起个名字。 我们建议您将其命名为index ,因为浏览器将始终自动从目录中提取index.html文件。 索引文件被读取为Web应用程序的首页。

    steps to create servlet application in netbeans
  12. Write some code inside your HTML file. We have created a hyperlink to our Servlet in our HTML file.

    在HTML文件中编写一些代码。 我们在HTML文件中创建了到Servlet的超链接。

    steps to create servlet application in netbeans
  13. Edit web.xml file. In the web.xml file you can see, we have specified the url-pattern and the servlet-name, this means when hello url is accessed our Servlet file will be executed.

    编辑web.xml文件。 在web.xml文件中,您已经指定了url-patternservlet-name ,这意味着当访问hello url时,将执行我们的Servlet文件。

    steps to create servlet application in netbeans
  14. Run your application, right click on your Project and select Run

    运行您的应用程序,右键单击您的项目,然后选择运行

    steps to create servlet application in netbeans
  15. Click on the link created, to open your Servlet.

    单击创建的链接,以打开您的Servlet。

    steps to create servlet application in netbeans
  16. Hurray! Our First Servlet class is running.

    欢呼! 我们的第一个Servlet类正在运行。

    steps to create servlet application in netbeans

翻译自: https://www.studytonight.com/servlet/creating-servlet-in-netbeans.php

netbeans ide

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值