The interceptor in struts2 is widely talked about and varied. Here are several common online sayings:
1. The principle of interceptor is dynamic proxy. (Nima)
2. The principle of interceptor is the responsibility chain model. (If there is no interceptor chain, it means it ad
Struts2 interceptors are similar to servlet filters. Before the Execute method of the action is executed, STRUTS2 first executes the reference in Struts.xmlInterceptor that executes the Execute method of the action after all the intercept methods of the referenced interceptor have been executed. In the Struts2
methods :First define the Interceptor --Specifies the number of parameters that the system initializes to the interceptor. Zhang added to your own set of interceptor stacks .Use of interceptors : 1. Define First ; 2. in reference use ;2:struts2 has a system default intercepto
Struts2 's interceptor is a good weapon! In particular, custom interceptors, the following is my personal collation of the entire process, I hope to bring you help, there is a better view of the hope that can provide valuable advice.Principle:A) The Web browser sends the requestb) First through a set of Struts2 default interception stacks dispatcher (or servletfi
This article is from: Cao Shenhuan blog column. Reprint Please specify source:http://blog.csdn.net/csh624366188
Interceptors (Interceptor) are one of the most powerful features of Struts2, and can be said to be the core of struts2, which allows you to do some processing before or after action and result are executed. At the same time, interceptors allow you to m
each request creates a new instance of the action, the Interceptor is reused, which means that the interceptor is stateless and does not store the data associated with the request currently being processed in the interceptor, which is not the role of the Interceptor. Interceptors should only apply its processing logic
attribute Set/get method;You can also set parameters for the interceptor when you use it:is configured below the reslut of an action as follows:class= "Com.zzz.struts2.action.RegisterAction" >2. The relationship between the Interceptor , the interceptor stack, and the default interceptor1: Interceptor and
Analysis and use of Struts2 interceptor
I. Case study: The result page is successfully displayed by filling in the form submission on the loginUI. jsp page. view the console output and get a preliminary understanding of the interceptor workflow.
Ii. Case Analysis:
A) create an Interceptor (MyInterceptor. java) to imp
sreadlocals.
1, the Interceptor is based on the Java reflection mechanism, and the filter is based on function callback.2, the filter relies on the servlet container, and the interceptor does not depend on the servlet container.3. The interceptor can only function on the action request, and the filter works on almost any request.4, the
In the previous article introduced the principle of the Struts2 interceptor, in this article we will learn how to write their own interceptor.
First, the implementation of the Interceptor
Implementing an interceptor is very simple. In fact, an
In the previous blog, introduced the Struts2 of the built-in interceptors and custom interceptors some content, but with these self-contained and custom interceptors, how to configure and use, have not explained to you in detail, then we will learn together, Configuration and use of interceptor in STRUTS2.
The Interceptor
Interceptor concept:
Interceptor is used in AOP (Aspect-OrientedProgramming) to intercept a method or field before it is accessed, and then add some operations before or after it. Interception is an implementation policy of AOP.
In the Chinese Document of Webwork, the interceptor is the object for dynamically intercepting Action calls. It provides a mechanism for
Summary: The Interceptor is a very important component of struts2 and an extremely subtle part of struts2. Many functions of struts2 are implemented through these interceptors, such as exception handling, file Upload request parameter assignment, data verification, and other functions are implemented in the
The Interceptor is deployed in almost every program. Therefore, the detailed process of the interceptor configuration is posted, hoping to help you.
Detailed configuration process of Struts2 interceptor
Zhang zhaozhao
You can also set parameters when using t
Struts2 Study Notes --- custom interceptorWhat is an interceptor?
In struts2, interceptors are divided into the interceptors defined by Struts2 and custom interceptors. It intercepts an Action before it is executed, and adds some operations after the Action is executed.Implementation Principle
When an Action is request
Interceptor systemIs an important part of the struts2 framework, a large numberBuilt-in interceptorCompleted most of the operations on the framework. For exampleParamsThe Interceptor is responsible for parsing HTTP Request Parameters and setting Action attributes;ServletconfigThe interceptor directly transmits the http
1. Interceptor: the interceptor is the core of struts2, and all functions of struts2 are implemented through the interceptor.
2. interceptor Configuration:
1) Write a class that implements the
Interceptor) is the core component of Struts 2. A lot of features) are built on the interceptor, such as file upload and download, internationalization, converter and data validation, Struts 2 uses the built-in interceptor, completed most of the operations in the framework. In Struts 2, the interceptor is interpreted a
Preface
As mentioned earlier, the interceptor can only intercept action. Here, the interceptor calls reflect the responsibility chain mode. Why does it reflect the responsibility chain model?
The following is a clear explanation:
Struts2 divides the entire execution into several elements of the same type. Each element has different logical responsibilities and
For example, if you often need to obtain the user currently logged on in the action, you need to obtain the session and then the user currently logged on from the session, because these steps are repeated, you can find a way to implement it in the Interceptor. You can customize an interface. As long as your action implements this interface, inject it in the Custom interceptor. That is, get the session from
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.