`
lysvanilla
  • 浏览: 78583 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

Field-Driven和Model-Driven

阅读更多

Struts2根据Action属性的不同将它分为两类:Field-Driven(属性驱动) Action和Model-Driven(模型驱动) Action。

 

一、Field-Driven(属性驱动)Action,Action拥有自己的属性,这些属性一般是Java的基本类型。表单字段直接和Action的属性对应。

 

二、实现了modelDriven接口可以在action中直接获得例如User对象,它会将Object getModel()取得的User放到ValueStack中。可以理解为将这个User的属性追加到Action中。它主要是作用是实现类似Struts的FormBean功能。 在struts2中,提供了一种直接使用领域对象的方式,就是让action实现com.opensymphony.xwork2.ModelDriven接口,ModelDriven让你可以直接操作应用程序中的领域对象,允许你在web层和业务层使用相同的对象。对于请求参数较多的情况,建议将请求参数封装到一个单独的JavaBean模型中,这样只要通过Action类ModelDriven接口,并且实现getModel()方法即可轻松是是实现模型驱动。

 

(1)模型驱动的Action必须实现ModelDriven接口,而且要提供相应的泛型,这里当然就是具体使用的Java Bean了。

 

(2)实现ModelDriven的getModel方法,其实就是简单的返回泛型的一个对象。

 

(3)在Action提供一个泛型的私有对象,并提供相应的getter与setter。

1
4
分享到:
评论

相关推荐

    Domain-Driven Design

    and the process and results of deep refactoring are major contributions to our field.' -Luke Hohmann, author of Beyond Software Architecture 'This book belongs on the shelf of every thoughtful ...

    Executable UML: A Foundation for Model-Driven Architecture

    Executable UML is a major innovation in the field of software development. It is designed to produce a comprehensive and understandable model of a solution independent of the organization of the ...

    Laboratory astrophysics with laser-driven strong magnetic fields in China

    On the Shenguang-II laser facility of the National Laboratory on High-Power Lasers and Physics, a laser-driven strong magnetic field up to 200 T has been achieved. The experiment was performed to ...

    ATL_User_Manual

    As opposed to this passive approach, the field of Model-Driven Engineering (MDE) aims to consider models as first class entities. It also considers that the different kinds of handled items (such as ...

    Professional ASP.NET MVC 5

    MVC 5 is the newest update to the popular Microsoft technology that enables you to build dynamic, data-driven websites. Like previous versions, this guide shows you step-by-step techniques on using ...

    Scala:Applied Machine Learning

    Implement scalable model monitoring and alerts with Scala In Detail This Learning Path aims to put the entire world of machine learning with Scala in front of you. Scala for Data Science, the first...

    The Indispensable PC Hardware Book - rar - part1. (1/7)

    The Field-effect Transistor. Basics of Machine-related Information Representation. Decimal and Binary Systems. ASCII Code. Negative Integers and Two's Complement. Hexadecimal Numbers. BCD...

    Deep Reinforcement Learning Hands-On: Apply modern RL methods, with deep Q-net

    The learning process is driven only by reward value and observations obtained from the environment. This model is very general and can be applied to many practical situations from playing games to ...

    Artificial Neural Networks_New Research-Nova Science(2017).pdf

    a practical model based on the multilayer perceptron neural network (MLP) approach to predict the milling tool flank wear in a regular cut, as well as entry cut and exit cut, of a milling tool;...

    springmybatis

    其实还有更简单的方法,而且是更好的方法,使用合理描述参数和SQL语句返回值的接口(比如IUserOperation.class),这样现在就可以至此那个更简单,更安全的代码,没有容易发生的字符串文字和转换的错误.下面是详细...

    Floquet spectrum and optical behaviors in dynamic Su–Schrieffer–Heeger modeled waveguide array

    Here, we implement the dynamic Su–Schrieffer–Heeger model in periodically curved waveguides to explore new behaviors in FTIs using light field evolutions. Changing the driving frequency produces ...

    UNIX Network Programming Volume 1, Third Edition (Unix网络编程卷1第3版英文版)

    OSI Model Section 1.8. BSD Networking History Section 1.9. Test Networks and Hosts Section 1.10. Unix Standards Section 1.11. 64-Bit Architectures Section 1.12. Summary Exercises ...

    sigmod2011全部论文(2)

    以前和大家分享过SIGMOD2009的论文,朋友们都很感兴趣,现手里有SIGMOD211的全部论文,再次和大家分享~ 一个包放不下,一共分成了3个包,包含百余篇论文,朋友们可以挑选自己感兴趣的部分下载,我尽量把文章目录写...

    Handbook of Research on Soft Computing and Nature-Inspired Algorithms

    proposedbyvariousresearchersinthisfield.Itcanbethestartingpointforthedesigningandmodelling newalgorithmsorimprovingexistingalgorithms. Chapter 6 ...

    spring-framework-reference-4.1.2

    Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................

    spring-framework-reference4.1.4

    Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................

    Software Testing and Continuous Quality Improvement

    19 Capability Maturity Model (CMM) . . . . . . . . . . . . . . . . . . . . . . . . . 20 Level 1 — Initial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 ...

    JavaEE 5.0 Tutorial.pdf

    Java EE ApplicationModel ................................................................................................................. 42 DistributedMultitiered Applications .........................

    [Go语言入门(含源码)] The Way to Go (with source code)

    The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................

Global site tag (gtag.js) - Google Analytics