2007-03-26
关于Struts MVC的疑惑
关于struts 的 web MVC,一直有个疑惑,请大家帮我理解一下.
在Struts中,"M" 应该指的什么?
在struts中,我一直理解为ActionServlet作为 "C",Action以及ActionForm 等作为"M",jsp作"V".
但看了spring的web mvc,引入了Front Controller,由DispatchSevlet作为一个分发器,将请求分发给Controller,在返回ModelAndView......
对比而言,如果将Struts中ActionServlet也理解为一个分发器,而将它的Action理解为"C",是不是也可以行的通?
不知道大家怎么看待Struts的MVC的.
在Struts中,"M" 应该指的什么?
在struts中,我一直理解为ActionServlet作为 "C",Action以及ActionForm 等作为"M",jsp作"V".
但看了spring的web mvc,引入了Front Controller,由DispatchSevlet作为一个分发器,将请求分发给Controller,在返回ModelAndView......
对比而言,如果将Struts中ActionServlet也理解为一个分发器,而将它的Action理解为"C",是不是也可以行的通?
不知道大家怎么看待Struts的MVC的.
- 16:08
- 浏览 (2150)
- 论坛浏览 (2570)
- 评论 (10)
- 相关推荐
评论
model 包括行为与属性 form+action比较合试。。
action并不决定向何方向分发页面。
Controller 是actionservlet + struts-config
V是指由jsp ->servlet而jsp本身不是V 只是个工具类而已。
action并不决定向何方向分发页面。
Controller 是actionservlet + struts-config
V是指由jsp ->servlet而jsp本身不是V 只是个工具类而已。
看看官方的介绍,我理解Action和ActionServlet一样也是Controller:
The framework provides its own web Controller component and integrates with other technologies to provide the Model and the View. For the Model, the framework can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, the framework works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.
The framework's Controller acts as a bridge between the application's Model and the web View. When a request is received, the Controller invokes an Action class. The Action class consults with the Model (or, preferably, a Facade representing your Model) to examine or update the application's state. The framework provides an ActionForm class to help transfer data between Model and View.
Most often, the Model is represented as a set of JavaBeans. Typically, developers will use the Commons BeanUtils to transfer data between ActionForms and the Model objects (or a Facade). Preferably, the Model will do the "heavy lifting", and the Action will act as a "traffic cop" or adapter.
The framework provides its own web Controller component and integrates with other technologies to provide the Model and the View. For the Model, the framework can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, the framework works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.
The framework's Controller acts as a bridge between the application's Model and the web View. When a request is received, the Controller invokes an Action class. The Action class consults with the Model (or, preferably, a Facade representing your Model) to examine or update the application's state. The framework provides an ActionForm class to help transfer data between Model and View.
Most often, the Model is represented as a set of JavaBeans. Typically, developers will use the Commons BeanUtils to transfer data between ActionForms and the Model objects (or a Facade). Preferably, the Model will do the "heavy lifting", and the Action will act as a "traffic cop" or adapter.
引用
struts是个框架技术而已。 module对应formbean。 controller对应action。 view对应jsp。ActionServlet的处理实际上还有交给Action做的,感觉应该属于C。
流程如下:
jsp --- form --- VO --- action(Control) --- PO \ / \ / 调用业务层对象\ /作为参数传到业务层 \ / \ / Model | | | 调用相应的持久化方法,把PO作为参数 ------------------------------------- jsp --- form --- VO 这三者,我们都可以理解为是展示层的东西, action是控制层, Model 是业务层,业务层可能要调用持久层的一些方法。 在展示层,我们只能够操作 VO , 在业务和持久层,我们只能操作 PO , 在action 中,我们可以对 两者之间进行转换,这样就达到了分层的目的,而且,在页面不会出现持久化对象,在业务层也不会出现值对象。 好的分层,可以是各个层次之间的偶合度很小,当一个部分发生改变的时候,只需要改变相应层次之间的映射,而不必改变其他的层。
流程如下:
jsp --- form --- VO --- action(Control) --- PO \ / \ / 调用业务层对象\ /作为参数传到业务层 \ / \ / Model | | | 调用相应的持久化方法,把PO作为参数 ------------------------------------- jsp --- form --- VO 这三者,我们都可以理解为是展示层的东西, action是控制层, Model 是业务层,业务层可能要调用持久层的一些方法。 在展示层,我们只能够操作 VO , 在业务和持久层,我们只能操作 PO , 在action 中,我们可以对 两者之间进行转换,这样就达到了分层的目的,而且,在页面不会出现持久化对象,在业务层也不会出现值对象。 好的分层,可以是各个层次之间的偶合度很小,当一个部分发生改变的时候,只需要改变相应层次之间的映射,而不必改变其他的层。
你的module 和 model是什么关系?
我觉得
引用
M是放数据用的,v从M里拿数据显示
比较好理解
formbean 是 model, Action等都认为是Controller,在Action中控制如何获取需要的Model即可
MVC是八十年代Smalltalk80引入的一种用户界面应用程序设计模型,经过二十多年的发展,到现在无论是Struts,Spring还是其他框架模型,都不能完全按照MVC去分解了,而是角色更加明确,分工更加细致。
对于刚刚了解面向对象分层体系的人,可以借助MVC去理解,去切入
这是我的理解
对于刚刚了解面向对象分层体系的人,可以借助MVC去理解,去切入
这是我的理解
struts是个框架技术而已。 module对应formbean。 controller对应action。 view对应jsp。ActionServlet的处理实际上还有交给Action做的,感觉应该属于C。
流程如下:
jsp --- form --- VO --- action(Control) --- PO \ / \ / 调用业务层对象\ /作为参数传到业务层 \ / \ / Model | | | 调用相应的持久化方法,把PO作为参数 ------------------------------------- jsp --- form --- VO 这三者,我们都可以理解为是展示层的东西, action是控制层, Model 是业务层,业务层可能要调用持久层的一些方法。 在展示层,我们只能够操作 VO , 在业务和持久层,我们只能操作 PO , 在action 中,我们可以对 两者之间进行转换,这样就达到了分层的目的,而且,在页面不会出现持久化对象,在业务层也不会出现值对象。 好的分层,可以是各个层次之间的偶合度很小,当一个部分发生改变的时候,只需要改变相应层次之间的映射,而不必改变其他的层。
流程如下:
jsp --- form --- VO --- action(Control) --- PO \ / \ / 调用业务层对象\ /作为参数传到业务层 \ / \ / Model | | | 调用相应的持久化方法,把PO作为参数 ------------------------------------- jsp --- form --- VO 这三者,我们都可以理解为是展示层的东西, action是控制层, Model 是业务层,业务层可能要调用持久层的一些方法。 在展示层,我们只能够操作 VO , 在业务和持久层,我们只能操作 PO , 在action 中,我们可以对 两者之间进行转换,这样就达到了分层的目的,而且,在页面不会出现持久化对象,在业务层也不会出现值对象。 好的分层,可以是各个层次之间的偶合度很小,当一个部分发生改变的时候,只需要改变相应层次之间的映射,而不必改变其他的层。
发表评论
该博客是同时发布到论坛的,无法评论在论坛已被锁定的帖子
最新评论
-
关于Struts MVC的疑惑
model 包括行为与属性 form+action比较合试。。 action并不 ...
-- by 抛出异常的爱 -
关于Struts MVC的疑惑
看看官方的介绍,我理解Action和ActionServlet一样也是Contr ...
-- by toowzh -
关于Struts MVC的疑惑
为什么很多书上提到struts时,一直都说ActionServlet是MVC的C ...
-- by wldandan -
关于Struts MVC的疑惑
FORM -> M ACTION -> C JSP -> v OTHERS ...
-- by 生命火花 -
关于Struts MVC的疑惑
引用struts是个框架技术而已。 module对应formbean。 cont ...
-- by wldandan







评论排行榜