`
wonderfan
  • 浏览: 13639 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

STRUTS2 IN DETAIL

阅读更多
when requests are received at the servlet container,they are forwarded to either a servlet or a filter that will handler processign the request. in struts2, a filter is used; and the class for handling the request is the filterdispatcher class.
the filter and a dispatcher class are the heart of the struts2 framewotk. together, they provide access to the infrastructure that will be needed to process the request. upon startup, implementations of configurable elements in the framework including configurationmanager,actionmapper and objectfactory are loaded. with respect to processign the request ,the struts2 filter performa the following: serves static content; determines the action configuration;create the action context;create the action proxy;performs cleanup. when the actionproxy class instance is created and  cpnfigued ,the excute() method is invoked. this signals that the preparation of the action is complete and the real processing of the action is about to start.
the actioninvocation object manages the execution environment and contains the conversational state of the action being processed, this class is the core of the actionproxy class. the execution environment is made up of three different components;action,interceptors and results. one of the first task that the actioninvocation performs is to consult the configuration being used and to create an instance of the action. unlike struts and other frameworks that reuse action instances,struts2 creates a new action object instance for each and every request that is received. there is a slight performance overhead with this approach,but you gain the adavantage that the object can behave as plain old java object.
interceptors provide a simple way to add prcoessing logic around the method being called on the action. they allowq for cross-functional features to be applied to actions in a convenient and consistent way, avoiding the need for adding code to each and every action that over time would create additonal maintenance overhead.  this funcitonality is similar to that provided by servlet filters and the jdk proxy object.
each action will have many interceptors configured. these interceptors are invoked in the order that they are configured. after they are all applied to the request, the actionss method that processes the logic for the request is called.
after the processing of the action is complete, it is time to turn your attention to the result. the method of the actin class that processes the request retruns a string as the result which is mapped via configuration to an implementation of the result  intreface or the action can directyly returnn a result object instance. the result interface is very similar to an action class; it contains a single method that generates a response for the user.
the only requirement for actions in struts is tha three must be one no-argument method that returns either a string or result object. if the no-argument method is not specified, the default behavior is to use the execute method. otherwise, you will need addtional configuration to specify the method name. the actionsupport class is more interesting. it implements the action interface and provides an implementation for the execute method the returns the success value. four other interface are also implemented .the validateable and validationaware interfaces as you would expect,provide the support for validation. these alloww the action to provide programmatic,annotation-based and declarative xml-based validation. the textprovider and localeprovider interfaces provides support for localization and internationalization.
interceptors allow for crosscutting functionality to be implemented separatley from the action as well as the framework. the first difference is that the contents of the stack are made up of four levels: temporary objects: these objects need temporary storage during the processing of a request. model object: when the action implements the modeldriven interface ,the model object is placed on the stack in front of the actipn that is being executed, this level will not be present if the interface is not implemented by the action. action object: this is the action that is currently being executed. named objects:any object can be assigned an identifier making it a named object. with the value stack, you are searching for or evaluarting a particular expression using object graph navigational language.
the result type provide the implementation details for the type of information that is retruned to the user. tag libraries provide the intersection between actions and views allowing dynamic informarion from the actions to be rendered as well as making rendering on the information to display at runtime.
following are the three main components that make up the struts2 tag architecture:model: the model component in the diagram is the component class. the web.xml configuration file is a j2ee configuration file that determines how elements of the http request are processed by the servlet container. the zero configuration terminology is used to describle the departure from a a pure xml-nased configuration to an annotation-based configuration.
you saw the interfaces  that need to be implemented to create custom result types and interceptors what interceptors look like and how to wire actions and configure them. use the new features direnctly in your web applications. bulder the new features into plug-in.
分享到:
评论
2 楼 gembler 2008-12-21  
wonderfan 写道
TALK ABOUT THE HTTO IN DETAIL

how?
1 楼 maleo 2008-12-21  
不知所云,还不如用汉语说呢,英语不好就不要拿出来,另外写错单词了

相关推荐

Global site tag (gtag.js) - Google Analytics