简体   繁体   English

Eclipse Luna IDE中MvC模式的工作流程

[英]working flow of MvC pattern in eclipse luna IDE

Am a beginner of eclipse ide user. 是Eclipse IDE用户的初学者。 Please can any 1 help me how mvc pattern link in eclipse hierarchy with an example. 请任何一位能帮我举例说明如何在eclipse层次结构中链接mvc模式。 Once project is created , under src/ folder create a necessary file and show me the flow of page linking from view to model and model to controller and to database using a login functionality. 创建项目后,在src /文件夹下创建一个必要的文件,并向我展示使用登录功能从视图到模型,从模型到控制器,再到数据库的页面链接流程。

I want to know where exactly what stuff to write, for example functions in one file , object and parameters in another , ids in jsp file. 我想知道到底要写些什么东西,例如一个文件中的函数,另一个文件中的对象和参数,jsp文件中的id。

It is up to you, usually you would be using a framework like Spring, 取决于您,通常您会使用Spring之类的框架,

MVC is simple but some people don't think correctly about it. MVC很简单,但是有些人对此并不正确。

V = View, this is your webpage/form/console output, There should be no logic in this code area. V =视图,这是您的网页/表单/控制台输出,此代码区域中不应包含逻辑。

C = Controller, this is your business logic, - Use Services and Managers to perform the tasks you want (UserService.getUsers(); or BasketService.getBasketForUser(UserService.getCurrentUser()); ) C =控制器,这是您的业务逻辑,-使用服务和管理器执行所需的任务(UserService.getUsers();或BasketService.getBasketForUser(UserService.getCurrentUser());)

Now we come to M = Model. 现在我们来谈谈M =模型。 most online tutorials refer to the model as the Database... 大多数在线教程都将模型称为数据库...

This is wrong. 错了 Let me describe a system i once worked on. 让我描述一下我曾经工作过的系统。

We loaded a Record or series of Records from the Database into ValueObjects. 我们从数据库中将一个记录或一系列记录加载到ValueObjects中。 We then Transformed these into DataTransferObjects which we used to transfer data around the system. 然后,我们将它们转换为DataTransferObjects,用于在系统中传输数据。

The DTO (Data Transfer Object) is the Model, as it is the Data that the Business Logic works on. DTO(数据传输对象)是模型,因为它是业务逻辑处理的数据。 and not the Database or Value Object (the system representation of the Database Records) as the Model may merge multiple Tables together to make a more useful DataModel. 而不是数据库或值对象(数据库记录的系统表示形式),因为模型可以将多个表合并在一起以构成更有用的数据模型。

As for structure you could do anything 至于结构,你可以做任何事情

/Services /服务

/DAOs / DAO

/Entities /实体

/View /视图

The answer from Theresa Forster is correct, however, as someone who worked many years with Eclipse, I want to add a few things. Theresa Forster的答案是正确的,但是,作为一个使用Eclipse已有多年经验的人,我想补充一些内容。

Eclipse has a strong eco-system of plugins that you can use (install) to your advantage. Eclipse有一个强大的插件生态系统,您可以使用(安装)自己的优点。 Some of these plugins seem to be what you need: 其中一些插件似乎正是您所需要的:

Additionally, if you feel like using the Spring framework to help you code, this may be useful as well: 此外,如果您想使用Spring框架来帮助编写代码,这也可能会很有用:

Spring has a strong ecosystem and is generally regarded as the way to go with MVC apps when using Eclipse for Java. Spring具有强大的生态系统,通常被视为使用Eclipse for Java时使用MVC应用程序的方式。 You can say that Spring is for Java as ASP.NET is for C#. 您可以说Spring是Java的,而ASP.NET是C#的。 Both are strong frameworks that help you with MVC. 两者都是可以帮助您使用MVC的强大框架。

If however, you don't want to go this way, you can always go hardcore and create the file structure yourself: 但是,如果您不想这样做,则可以随时进行核心操作并自行创建文件结构:

Hope I helped ! 希望我有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM