In MVC pattern, can the Model interact / modify the View?

后端 未结 3 970
囚心锁ツ
囚心锁ツ 2021-01-21 01:58

The MVC pattern component interactions are described this way on Wikipedia:

The model is responsible for managing the data of the applica

3条回答
  •  一整个雨季
    2021-01-21 02:08

    Diagrams - worth a thousand words! The precise words and context used in the diagram maybe doesn't tell a story of implementation, say in Microsoft MVC 5/6.

    A user's interaction is with the controller. Not the view and not the model. Calling an action on a controller will return something (a view, a file, a redirect, etc.).

    In the case of returning a view of information, the controller, having worked out what data the user is requesting can retrieve a model that fits the request, pass this into a view, and return the view result of this model.

    In the diagram above it isn't clear that the controller is acting as the agent in moving the model into the view. the model does not decide on the view. Why? Depending on what is in the model returned the controller, a different view might be returned. That is why the controller is aptly named. It sits at the centre of affairs making decisions and moving objects around.

    So what you are missing is some context about how the process of MVC occurs when implemented

提交回复
热议问题