actions in the module must share the same lifecycle.• Struts2 supports creating different lifecycles for each Action through Interceptor Stacks. The stack can be used with different actions as needed.Struts. action. extensionThe URL extension to use to determine if the request is meant for a Struts actionUse the URL extension to determine whether the request is used as a Struts action, that is, to set the
In the previous article we analyzed the Arouter routing jump, this article we analyze the Interceptor interceptor.
First, the interceptor also produces the corresponding file during the IDE compilation process. (See Arouter source Analysis 01-Compile the generated file)
public class arouter$ $Interceptors $ $app implements Iinterceptorgroup {
@Override public
sequence diagram:
The workflow of Struts2 is a core content of Struts2. Other content is also centered on its workflow, which is based on the extension. This blog is also a more detailed theoretical description of the previous article.
Struts2 Workflow
The main workflow of struts2 is as follows:First, an http reques
"Encapsulates an INPUT element in a Web page as a (request) data Object", an object that isThe actioninvocation type.For Xwork, the webwork component of the front-end provides a data structure of a map type. The action is oriented to the data structure provided by the model object. When and where do you convert these two different data structures?Write a helper class to do the work, and call him to complete the conversion work before each action call by the framework code.Xwork This step through
-validation.xml configuration struts.xml file Add Manual completion of validation requires overriding the Validate () method, overriding the ValidateXxx () method First, understand the interceptor :The 1.struts2 interceptor is a method that accesses an action or action, the field is intercepted before or after it, and the
SpringMVC-detailed interceptor process, use and customize interceptor
First, let's look at what the interceptor does:
1. Logging: records the request information logs for information monitoring, information statistics, and calculation of PV (PageView.
2. Permission check: for example, if logon is detected, go to the processor check to check whether or not to log
First, Interceptor method
The EJB3 can intercept and overwrite bean methods through interceptors. This is somewhat like the around in AOP. The around method of AOP can modify the return value, parameter value of the blocked method, and even cancel the execution of the blocked method. EJB3 interceptors can be used in stateless session beans, stateful session beans, and message-driven bean (MDB) methods. The easiest way to implement interceptors is to
. xml) through ConfigurationManager and finds the Action class to be called.6. Create an ActionInvocation instance using ActionProxy7. ActionInvocation calls the real Action. Of course, this involves the call of the relevant interceptor (interceptor)8. After the Action is executed, ActionInvocation creates the Result and returns the Result. You can also perform some actions before returning the Result.What
of the prehandle method of the currently-owned true is the same. The posthandle method, as the name implies, is executed after the current request is processed, that is, after the controller method call, but it is called before the view is returned to render dispatcherservlet. So we can manipulate the modelandview object after controller processing in this method. The posthandle method is called in the opposite direction to prehandle, which means that the posthandle method of the first declarat
Two-step configuration Spring MVC Interceptor Interceptor One interceptor first step to implement Handlerinterceptor interface The second step registers into spring
Two-step configuration Spring MVC Interceptor Interceptor A. Interceptor
above interceptor as the default interceptor:
This will be blocked by login until all the action within the same package is executed.
Struts2 (Xwork ) provides a description of the function of the Interceptor:
Intercepting Device
name
Description
Alias
RecoveryInterceptor: Interceptor.While we declare the interceptor (the default interceptor will not work at this time), we must add the default interceptor provided by STRUTS2 (otherwise the return information of the access page may surprise you, such as a bunch of messy information about the submitted form information
in channelmapping, if NULL ( Indicates that the default Send list Defaultchannels is returned because the headers of the event does not have a matching channel sent to the default channel.
Second, channelprocessor channelprocessor = new Channelprocessor (selector) This is the encapsulation selector construct channelprocessor. Its construction method assigns a value selector and constructs a Interceptorchain object interceptorchain. The Channelprocessor class is responsible for managing selecto
Struts2 organization ----- Struts2 introduction, struts2 Introduction
Struts2 introduction:
Struts2 developed on the basis of webwork2. Like struts1, struts2 also belongs to the MVC framework. However, although
Since the work in the past two months has been relatively idle, I am also relatively "advanced", and I continue to learn about the difference between struts2 and struts1, why does struts1 use servlet while struts2 uses filter? What is the difference between Servlet and filter? So I looked at web. xml and found again, Servlet, filter, listener? Is there an interceptor
The Java Web Project uses the structure of the spring+spring mvc+hibernate, and the methods in the controller are used to process the front-end access information. The controller returns a Modelandview object to the front end or only JSON-formatted data by invoking the service for business processing. It is convenient for development and debugging if you can get information about HTTP requests that are processed in the backend program. Interceptor, wh
can be substituted.
Many of the features provided by the STRUTS2 framework use examples of interception implementations, including exception handling, file uploads, lifecycle callbacks, and validations, which, in fact, serve as the basis for Struts2, which function to intercept, which may have 7 or 8 interceptors assigned to each action.
Interceptor for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.