Java-学习MVC[英] Java - Learning MVC

本文是小编为大家收集整理的关于Java-学习MVC的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我希望学习如何将MVC架构应用于我的Java项目;主要是我的工作.现在没有简单的解释或示例如何使用MVC编写正确的代码,除了我在此处找到的这两个:

  1. 40mvc.html
  2. Javase/MVC-136693.html

在我看来,Java中没有定义的MVC架构.从我看的是,Java在WWING的基本级别上为您提供了什么,您可以独自应用于第一个教程.

除了上面的两个资源外,有人可以为我提供可以将您放松到Java MVC的来源吗?视频教程可能?

推荐答案

这是一个很不错的例子 http:///www.leepoint/gui/struction/40mvc.html 我试图找到最简单的可能让您感受到这个想法.

无论如何我都不喜欢:

在我看来,Java中没有定义的MVC架构.

您可以使用各种不同语言的MVC,MVP和所有其他模式. Java与MVC无关,除了可以在Java中编码MVC设计.但是,有些框架嵌入了MVC架构及其力量. 春季MVC 是最著名的 - 尝试找到有关它的更多信息,也许是一些教程.

其他推荐答案

模型 - 模型代表携带数据的对象或Java Pojo.如果其数据更改,它也可以具有更新控制器的逻辑.

视图 - 视图表示模型包含的数据的可视化.

控制器 - 控制器在模型和视图上都作用.它将数据流控制到模型对象中,并在数据更改时更新视图.它可以将视图和模型分开.

mvc简单示例

其他推荐答案

请参见此示例本文地址:https://www.itbaoku.cn/post/627666.html

问题描述

I wish to learn how to apply MVC architecture to my Java project; mainly my work in Swing. Now there is no easy explanation or example how to write proper code using MVC in mind apart from these two I found here:

  1. http://leepoint.net/notes-java/GUI/structure/40mvc.html
  2. http://www.oracle.com/technetwork/articles/javase/mvc-136693.html

It seems to me there is not a defined MVC architecture in Java. From what I looked at it's what Java offers you at the base level of Wwing and what you can apply on your own is in the first tutorial.

Apart from the two resources above, can someone provide me with a source that can ease you in to Java MVC? A video tutorial maybe?

推荐答案

Here is pretty nice example http://www.leepoint.net/GUI/structure/40mvc.html I tried to find simplest possible to let you feel the idea.

Anyway I don't like the:

Seems to me there is not a defined MVC architecture in Java.

You can use MVC, MVP and whole other patterns in various different languages. Java has nothing to do with MVC, except MVC design can be coded in Java. There are, however, some frameworks that have embedded MVC architecture and forces using it. Spring MVC is the most known - try to find more about it, maybe some tutorials.

其他推荐答案

Model - Model represents an object or JAVA POJO carrying data. It can also have logic to update controller if its data changes.

View - View represents the visualization of the data that model contains.

Controller - Controller acts on both Model and view. It controls the data flow into model object and updates the view whenever data changes. It keeps View and Model separate.

mvc simple example

其他推荐答案

see this example mvc simple example which is adding two numbers program using swings.by this example you can easily understud the concept of mvc