且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java/Jakarta EE Web开发,我从哪里开始?我需要什么技能?

更新时间:2023-12-04 07:58:10

(2021年4月更新)

首先,"Java EE"自2019年9月起,它已从版本8重命名为" Jakarta EE ".从历史上看,术语"J2EE"其中涵盖了1.2到1.4版本.所述"Java EE"指的是"Java EE".涵盖版本5到8.另请参见 Java平台,企业版,Wikipedia上的历史记录.

First of all, "Java EE" has since Sep 2019 been renamed to "Jakarta EE", starting with version 8. Historically, there was also the term "J2EE" which covered versions 1.2 until 1.4. The "Java EE" covered versions 5 until 8. See also Java Platform, Enterprise Edition, History on Wikipedia.

我到底需要学习什么?

我假设您已经熟悉客户端技术,例如 HTML CSS Java教程,如果可能的话,请获取

I assume that you're already familiar with client side technologies like HTML, CSS and JS, so I won't go in detail with that. I also assume that you're already familiar with basic Java. Follow Oracle's The Java Tutorials and if possible, go get a OCP book or course as well.

然后,您可以从JSP/Servlet开始学习Java Web开发的基本概念.好的教程可以在 Jakarta EE教程第18章"Jakarta Servlet Technology"中找到一个>.请注意,自Java EE 6开始,出于此目的,JSP已从教程中删除自从JSF 以来,该JSP基本上没有发生变化.这就是为什么您可以安全地使用相当老的 Java EE 5教程为此.关于JSP的最重要的事实是,自2003年以来,正式禁止使用<%脚本集%> 在JSP文件中编写纯Java代码.另请参见如何使用JSP 2避免JSP文件中的Java代码?因此,任何仍覆盖脚本的教程都应该跳过,因为它们肯定会带您学习不良实践的螺旋式下降.

Then you can start with JSP/Servlet to learn the basic concepts of Java web development. Good tutorial can be found in Jakarta EE tutorial chapter 18 'Jakarta Servlet Technology'. Note that since Java EE 6, JSP is removed from the tutorial in favor of JSF and that JSP has basically not changed since then. That's why you could safely use the fairly old Java EE 5 tutorial for this. Most important thing with regard to JSP is the fact that writing plain Java code in JSP files using <% scriptlets %> is officially discouraged since 2003. See also How can I avoid Java code in JSP files, using JSP 2? So any tutorials which still cover scriptlets should be skipped as they will definitely take you into a downward spiral of learning bad practices.

在堆栈溢出方面,您还可以找到有关 JSP Servlets JSTL

Here on Stack Overflow, you can also find nice wiki pages about JSP, Servlets, JSTL and EL where you can learn the essentials and find more useful links.

Tomcat似乎是Java的良好Web服务器.

是的.但是,它的功能有限.它基本上是一个准系统的servlet容器,仅实现了巨大的Java EE API的JSP/Servlet部分.如果您想使用EJB或JPA,那么您想选择另一个,例如 WildFly TomEE Payara WebLogic 等等.否则,您必须使用Spring而不是Java EE.也就是说,如果不修改核心引擎就无法在准系统servlet容器中安装EJB,以防Tomcat基本上是在重塑TomEE.另请参见 Java EE到底是什么?如何通过Maven正确安装和配置JSF库?如何在Tomcat上安装和使用CDI? >


It is. It is however limited in capabilities. It's basically a barebones servlet container, implementing only the JSP/Servlet parts of the huge Java EE API. If you ever want to go EJB or JPA, then you'd like to pick another, e.g. WildFly, TomEE, Payara, Liberty, WebLogic, etc. Otherwise you have to use Spring instead of Java EE. It's namely not possible to install EJB in a barebones servlet container without modifying the core engine, you'd in case of Tomcat basically be reinventing TomEE. See also What exactly is Java EE?, How to properly install and configure JSF libraries via Maven? and How to install and use CDI on Tomcat?

我知道有一个适用于ORM的Hibernate.

以前,在J2EE时代,当JPA不存在并且EJB2糟糕时,Hibernate是一个独立的框架,经常与Spring结合使用以取代EJB.自从Java EE 5(2006)中引入JPA以来,Hibernate已成为JPA实现.您可以在 Jakarta EE教程第八部分中学习JPA.另外,基于从Spring中学到的经验教训,EJB3也得到了很大的改进.另请参见何时有必要或方便地同时使用Spring或EJB3或将它们全部一起使用?

Previously, during the J2EE era, when JPA didn't exist and EJB2 was terrible, Hibernate was a standalone framework and often used in combination with Spring to supplant EJB. Since the introduction of JPA in Java EE 5 (2006), Hibernate has become a JPA implementation. You can learn JPA at Jakarta EE tutorial part VIII. Also, EJB3 was much improved based on lessons learnt from Spring. See also When is it necessary or convenient to use Spring or EJB3 or all of them together?

Java是否有MVC?那JSP呢?MVC和JSP可以在一起吗?JavaBeans?

可以,但是很多 JSF .在Java EE 6之前,它曾经在JSP上运行,这是一种相当古老的视图技术.JSP已由 Facelets 代替.您可以在 Jakarta EE教程第三部分第7至17章中学习JSF..顺便说一下,您也可以在Tomcat上使用JSF,只需单独安装即可.可以在 Mojarra主页中找到安装说明.作为完整的Jakarta EE实现,WildFly,TomEE,Payara,Liberty,WebLogic等已经提供了开箱即用的JSF(以及CDI,BV,JSONP,JAX-RS,EJB,JPA等),因此您无需单独安装.另请参见如何通过Maven正确安装和配置JSF库?

You can, but that's a lot of reinvention of the wheel when it comes to tying the model with the view (conversion, validation, change listeners, etc). Jakarta EE's MVC framework is called JSF. Prior to Java EE 6 it used to run on JSP, which is a fairly legacy view technology. JSP is been replaced by Facelets. You can learn JSF at Jakarta EE tutorial part III chapters 7 - 17. You can by the way also use JSF on Tomcat, you only have to install it separately. Installation instructions can be found at Mojarra homepage. WildFly, TomEE, Payara, Liberty, WebLogic, etc as being a complete Jakarta EE implementation already provide JSF (and CDI, BV, JSONP, JAX-RS, EJB, JPA, etc) out the box, so you don't need to install it separately. See also How to properly install and configure JSF libraries via Maven?

也许是一本涵盖所有这些内容的书?

有几本书.我建议从一本专注于Jakarta EE的书开始一般而言,这本书更加专注于JSF 和一本书更加专注于JPA .确保选择涵盖该主题的最新书籍.首先调查最新的可用版本,然后确保所选择的书涵盖了该版本.因此,尽管目前已经有Jakarta EE 8和JSF 2.3可用,但是绝对不要选择Java EE 5或JSF 1.0左右的旧书.

There are several books. I would recommend to start with a book focused on Jakarta EE in general, a book more focused on JSF, and a book more focused on JPA. Ensure that you choose the most recent book covering the subject. First investigate the most recent available version and then ensure that the chosen book covers that. Thus do definitely not pick an old book for Java EE 5 or JSF 1.0 or so while there's currently already Jakarta EE 8 and JSF 2.3 available.

最后但并非最不重要的一点,请忽略业余爱好者维护的代码片段抓取站点,这些站点主要关注广告收入而不是教学,例如roseindia,tutorialspoint,javabeat,journaldev,javatpoint,codejava等.包含 scriptlets

Last but not least, please ignore code snippet scraping sites maintained by amateurs with primary focus on advertisement income instead of on teaching, such as roseindia, tutorialspoint, javabeat, journaldev, javatpoint, codejava, etc. They are easily recognizable by disturbing advertising links/banners and JSP code snippets containing scriptlets.