启动 Java EE MVC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1286019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:57:32  来源:igfitidea点击:

Starting Java EE MVC

javajakarta-ee

提问by Voxl

I'm trying to learn Java EE, starting with Servlets and JSPs in an MVC architecture. I know Servlets are often used as the controller and JSPs are often used as the view, and that these both interact with the model, the back end java application on the server. The question I'm asking is what the back end application would consist of. Is it nothing more than a simple JSE application that uses Servlets and JSPs as the interface?

我正在尝试学习 Java EE,从 MVC 架构中的 Servlet 和 JSP 开始。我知道 Servlet 通常用作控制器,而 JSP 通常用作视图,并且它们都与模型(服务器上的后端 Java 应用程序)进行交互。我要问的问题是后端应用程序将包含哪些内容。不就是一个简单的JSE 应用程序,使用Servlets 和JSPs 作为接口吗?

Also, considering I'm asking what's probably a simple question, is there a good Java EE MVC tutorial I could use?

另外,考虑到我在问什么可能是一个简单的问题,是否有我可以使用的好的 Java EE MVC 教程?

回答by Jim Ferrans

The Java EE components all run on the server side, either on full Java EE servers like GlassFish, JBoss, WebLogic, or WebSphere, or on servers like Tomcat that just support servlets and JSPs.

Java EE 组件都在服务器端运行,要么在完整的 Java EE 服务器(如 GlassFish、JBoss、WebLogic 或 WebSphere)上,要么在仅支持 servlet 和 JSP 的服务器(如 Tomcat)上运行。

In Java EE the MVC modelcan be thought of as a "domain model", ie the Java objects representing the entities that are important to your application. For instance a shopping application would have domain objects representing items for purchase, shopping carts, credit cards, mailing addresses, accounts, reviews, and so forth. Often these domain objects come from persistent storage such as a relational database.

在 Java EE 中,MVC模型可以被认为是一个“域模型”,即代表对您的应用程序很重要的实体的 Java 对象。例如,一个购物应用程序将具有代表要购买的项目、购物车、信用卡、邮寄地址、帐户、评论等的域对象。通常,这些域对象来自持久性存储,例如关系数据库。

Java EE's Java Persistence API is designed to handle the mapping between the Java domain model objects and the relational database tables used to make the objects persistence. Hibernateis one implementation of a JPA "object-relational mapper" (ORM).

Java EE 的 Java Persistence API 旨在处理 Java 域模型对象与用于使对象持久化的关系数据库表之间的映射。 Hibernate是 JPA“对象关系映射器”(ORM)的一种实现。

Java EE is much more than that. To take just one example, it defines an ultra-reliable messaging service (Java Message Service) that back end application components use to communicate with each other.

Java EE 远不止这些。仅举一个例子,它定义了一种超可靠的消息服务(Java Message Service),后端应用程序组件使用它来相互通信。

As you explore Java EE, do give some thought to simpler and more productive alternatives like Ruby-on-Rails, LAMP stacks, Microsoft's .NET platform, and "light-weight" Java approaches like Spring/Hibernate. Richard Monson-Haefel, who wrote O'Reilly's very successful "Enterprise JavaBeans 3.0" (the fifth edition) and "Java Message Service", even goes so far as to claimthat Java EE is "intimidating" to developers and will be eclipsed by these other approaches.

在您探索 Java EE 时,一定要考虑一些更简单、更高效的替代方案,例如 Ruby-on-Rails、LAMP 堆栈、Microsoft 的 .NET 平台和“轻量级”Java 方法(例如 Spring/Hibernate)。编写了 O'Reilly 非常成功的“企业 JavaBeans 3.0”(第五版)和“Java 消息服务”的 Richard Monson-Haefel 甚至声称Java EE 对开发人员来说是“令人生畏的”,并将被这些其他方法。

A good place to get a wider perspective is Todd Hoff's wonderful blog at http://highscalability.com/

获得更广阔视野的好地方是 Todd Hoff 在http://highscalability.com/ 上的精彩博客

回答by krishna

Similar question has been asked on SO, i think.

我想在 SO 上也有人问过类似的问题。

Here's a good tutorial to get you started.

这是一个很好的教程,可以帮助您入门。

http://courses.coreservlets.com/Course-Materials/csajsp2.html

http://courses.coreservlets.com/Course-Materials/csajsp2.html

回答by janetsmith

  1. To do java web programming, servlet is not a must. You can simply use jsp, like the way people program php & asp. It's fairly straight forward, and get u started easily. This is called Model 1 method.
  2. For Model 2 programming model, if you really want to do MVC programming, you can study "Page Controller" and "Front Controller" design patters to understand how they work behind the scene.

    If you want to use ready-made framework, you can try out Spring MVC.

  1. 做java web编程,servlet不是必须的。您可以简单地使用 jsp,就像人们编写 php 和 asp 的方式一样。它相当简单,让您轻松上手。这称为模型 1 方法。
  2. 对于 Model 2 编程模型,如果你真的想做 MVC 编程,你可以研究“Page Controller”和“Front Controller”的设计模式,了解它们在幕后是如何工作的。

    如果你想使用现成的框架,你可以试试Spring MVC。

http://www.vaannila.com/spring/spring-mvc-tutorial-1.html

http://www.vaannila.com/spring/spring-mvc-tutorial-1.html

good luck.

祝你好运。