Struts2 custom interceptor and struts2 custom Interception
The first is the two main files in the struts2 framework: one is the interceptor class and the other is the struts. xml configuration file.
To put it simply, one is to explain what to do, and the other is to explai
There are three methods to implement the Interceptor:
L implement the interceptor Interface
The interceptor interface has three methods:
Public interface interceptor extends serializable {Void destroy ();Void Init ();String intercept (actioninvocation Invocation) throws exception;}
L inherit the abstrac
When configuring a package, you can specify the default interceptor for it. Once a default interceptor is specified for a package, if the action in the package does not explicitly specify the interceptor, the default interceptor will take effect. Note: once an interceptor is
-Receive, type auto-convert, etc.) after configuration, indicate which interceptor to intercept which action or action, So that the interceptor will intercept our action. Each interceptor can add a new function to our action.2. How interceptors (Interceptor) workA. Class with an in
Downpour writes that interceptors are the concept of AOP, which is itself a piece of code that can be used to intercept the code of the Interceptor by defining the "weaving point" to execute before and after the "weaving point". As reference in Struts2 above, Struts2 's interceptor, the object of its interception is th
interceptor is based on the Java reflection mechanism, and the filter is based on function callback.2. The filter depends on the servlet container, and the interceptor does not rely on the servlet container.3. the interceptor can only work on Action requests, while the filter can work on almost all requests.4. the intercepto
General web site to prevent people from malicious login (not logged in directly to the background page), will use interceptor interceptor to limit login.
Below is a small example of an interceptor login limit that helps understand and apply interceptors. The basis for intercepting in interceptors is to see if there is any user information in the session scope.
If
Interceptor aboveNote that the action configuration, @ParentPackage need to be set to the Interceptor's package name or inheritance, or an errorThe error message is:"Unable to find interceptor class referenced by Ref-name XYZ" because the Interceptor Convention scan the action class, there is no interceptor specified
Interceptor OverviewAn interceptor is a set of objects that dynamically intercept action calls. The handler code for the interceptor can be defined before or after the action is executed. At the same time, the interceptor can intercept the execution of an action. Interceptors can encapsulate some common functionality i
The struts2-2.5.5 version is the latest version so far, and the new version has changed a lot compared to the previous version 2.3 and the previous versions.All right, nonsense, GO code!.Basic JAR Package:Web. XML Core configuration, here to pay attention to!class>org.apache.struts2.dispatcher.filter.strutsprepareandexecutefilterclass> /*Web. XMLNext up is struts.xml.the. Action request is handled by Struts 2. If the user needs to specify multiple req
Today, I spoke to several Java-loving students about struts2 and focused on its most valuable interceptor.
I don't know whether you can remember it. In struts2 server-side verification, I said, "The verification has been completed before arriving at the login action ". I hope someone can raise the question, so that I can say that this is the benefit of the
default interceptor and Interceptor chain in the struts-default.xml of the Struts2 jar package.STRUTS2 (Xwork) provides an interceptor function description:
Interception device
Name
Description
Alias Interceptor
Alias
The requ
Document directory
1. Configure the custom interceptor and interceptor Stack
3. Method Filtering
1. Introduction to interceptor
The Interceptor is the most important component of struts2, because most operations of struts2 are
This article is from: Cao shenghuan blog column. Reprinted please indicate the source:Http://blog.csdn.net/csh624366188
Interceptor is one of struts2's most powerful features. It can also be said to be the core of struts2. It allows you to process the action or result before or after it is executed. At the same time, the int
1. What is an interceptor:Interceptor, used in AOP (Aspect-Oriented Programming) 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.
2. Struts2 default interceptor Stack:
Interceptor
Name
Description
Alias
Software design dry rules, that is, do not write repetitive code, which can greatly reduce the workload of late maintenance. But the problem is, duplicate code is unavoidable, such as the user before sending a request to determine whether the user login, how to do it. The duplicate code is then extracted and encapsulated into a method A, which avoids writing duplicate code, and the user simply calls method a before sending the request. But again, the problem arises, the user may call method A be
Pee InterceptorIt can be said that the "interceptor" is the key content of Struts2. See the name of the meaning, the role of interceptors is mainly to intercept things, intercept what? Of course ' action ', the interceptor works before executing ' action ', executes some pre-processed code, then executes the associated method in the action, and then the process g
The Interceptor in Struts2 (frame function Core)
1, Filter vs Interceptor
Filter vs Interceptor functionality is one thing. Filters are techniques in the servlet specification that can filter requests and responses.
Interceptors are techniques in the STRUTS2 framework tha
The purpose of this blog: ① summary of their own learning process, equivalent to study notes ② to share their own experience to everyone, learn from each other, communication, not commercialcontent inevitably appear problems, welcome to correct, exchange, discussion, you can leave a message, can also be contacted by the following ways. I Internet technology enthusiasts, Internet technology enthusiastsWeibo: Ivan is in 0221qq:951226918--------------------------------------------------------------
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.