使用Model View Controller Java加载文件(Loading a file using Model View Controller Java)

系统教程 行业动态 更新时间:2024-06-14 16:57:39
使用Model View Controller Java加载文件(Loading a file using Model View Controller Java)

我试图读取一个txt文件,然后在视图的下拉选择器中使用该文本文件中的一些信息。 虽然,我不确定MVC的哪个部分应该包含该文件的加载,以及我如何将该信息提供给下拉列表。

我在想我在Controller中加载文件并将信息发送到View但不确定。

I am trying to read a txt file and then use some of the information in that text file in a drop down selector in the View. Though, I am unsure which part of the MVC the loading of the file is supposed to go in, and how I get that information to the drop down.

I was thinking I load the file in the Controller and send the info to the View but am unsure.

最满意答案

MVC背后的核心思想是,您应该能够“切掉”视图和控制器,并且如果必须更改图形框架,仍然可以保留模型部分。 因此,文件加载和写入属于模型类。 因此,您可以使用模型中存储的数据填充视图和控制器。

The core idea behind MVC is that you should be able to "slice away" the view and controller and still be able to retain the model portion if you had to change graphical frameworks. Thus, file loading and writing belongs in the model classes. You therefore populate the views and controllers with the data stored in the models.

更多推荐

本文发布于:2023-04-13 11:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/471360a98ce43b32bcafb08e29af3094.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   文件   Controller   View   Model

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!