我试图读取一个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.
更多推荐
发布评论