哪些文件专门负责struts2 MVC框架中的模型,视图和控制器? [英] Which files are responsible specifically for Model, View and Controller in struts2 MVC framework?

查看:93
本文介绍了哪些文件专门负责struts2 MVC框架中的模型,视图和控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MVC概念不清楚.

My MVC concept is not clear.

在我看来,.xml文件用于建模.jsp文件用于查看.java文件用于控制.这实际上代表了MVC系统.

It seems me that .xml files are for Modeling; .jsp files are for Viewing; .java files are for Controlling. This is actually represents MVC system.

我对MVC公式具有基本的工作概念,但是不清楚具体负责哪些文件?

I have the working basic concepts on MVC formula but I am not clear on which files are responsible specifically?

推荐答案

首先,进入您对MVC的概念是错误的,因此使用技术(.xml,.jsp,.java ...)划分概念

Your conception of MVC is wrong, and so is dividing concepts using technologies (.xml, .jsp, .java...);

  • 模型 包含数据(显示的内容);
  • 视图 将数据提供给用户(显示方式);
  • 控制器 自动或基于用户的交互(为什么会显示)来操纵数据.
  • The Model contains the data (WHAT is displayed);
  • The View renders the data to the user (HOW it is displayed);
  • The Controller manipulates the data, both automatically or based on user's interaction (WHY it is displayed).

然后,当您清楚什么是MVC时,请尝试了解Struts2如何实现MVC:

Then, when you've clear what MVC is, try to understand how Struts2 implements MVC:

  • the JSP file is the View;
  • the Action is the Controller (and part of the Model);
  • the Model is whatever you use to carry the data (Bean, POJO, Map, String, etc...), unless you explicitly define a model object through ModelDriven (but don't), in which case that object is the Model.

EDIT :正如Dave所建议的那样,值得一提的是,在谈到Actions时,我们还暗示了StrutsPrepareAndExecuteFilter(负责调用哪个Action)和Interceptor Stack(通过该拦截器每个操作都必须在结果执行之前和之后通过.

EDIT: as suggested by Dave, it is worth mentioning that, when talking of Actions, we're also implying the StrutsPrepareAndExecuteFilter (responsible of which Action to call) and the Interceptor Stack (through which every Action must pass before - and after - a result execution).

这篇关于哪些文件专门负责struts2 MVC框架中的模型,视图和控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆