Custom interceptor
1). Detailed steps
I. Define an interceptor class
> Interceptor interfaces can be implemented.> Inherit the abstractinterceptor abstract class
Ii. Define the functions of the interceptor in the Interceptor () method of the
1. interceptor
Interceptor is one of struts2's most powerful features. It allows you to process the action or result before or after execution. At the same time, the interceptor allows you to modularize common code and use it as a reusable class. Many features of struts2 are implemented by the interceptor. For example,
How to Develop a java open-source framework ----- implement custom Annotation and interceptor in the Jvn framework (Lecture 5) ----- jvnannotationPreface
I,
The blogger is teaching you how to develop a javaEE framework (Jvn framework). The blog has a complete development video. Every blog post is a knowledge point to help you understand the framework:
This content: http://pan.baidu.com/s/1hq3sng4
1. Why should we use the java framework and what benefi
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 is incorporated into a chained data structure
1.1 What is an interceptor:Interceptors, which are used in AOP (aspect-oriented programming) to intercept a method or field before it is accessed, and then add some action before or after it. Interception is an implementation strategy of AOP.The Chinese document in WebWork is interpreted as--interceptors are objects that dynamically intercept action calls. It provides a mechanism to enable developers to define code that executes before and after an action executes, or to prevent it from executin
The preceding method of manual file filtering is simple, but after all, a large amount of filtering code needs to be written, which is not conducive to high-level deconstruction of the program and complicated development.
Struts 2 provides a file upload Interceptor. By configuring this interceptor, you can easily filter files. In Struts 2, the file upload interceptor
There are a lot of Java beginners for the MyBatis interceptor Inteceptor is not very understanding, here I will organize the next chapter on the Java MyBatis Interceptor Inteceptor detailed,
This paper mainly analyzes the plug-in mechanism of mybatis, in fact, is the implementation of the responsibility chain model of Java dynamic Proxy implementation.
According to the official document. MyBatis only allo
And of course there are many interceptor stacks, so let's look at the interceptor first.
Interceptor name
Aliasinterceptor
"Alias Blocker"
Configuration name
Alias
Describe
Allows parameters to use different aliases across multiple requests, which can be used to link multiple actions with different names, and
Learn notes for the action before the interceptor or after the interceptor. from
After the teacher's test ... Add breakpoints to each interceptor ...Know:
The Action is executed at the time of the visit.
And the action is created before the params interceptor is executed.
So the conclusion is:
Action must precede the
Directory
Objective
Important interface and class introduction
SOURCE Analysis
Interceptor Configuration
Writing a custom Interceptor
Summarize
ObjectiveSPRINGMVC is currently one of the mainstream web MVC frameworks.If a classmate is unfamiliar with it, then please refer to it's Getting started blog:http://www.cnblogs.com/fangjian0423/p/springmvc-introduction.htmlIntercept
The struts2 interceptor is one of the core functions of the struts framework. First, the automatic data filling function implemented by the struts framework is implemented by the interceptor. Here we will summarize the experiences of the blocker during this period.
It is obvious that the interceptor must be pre-processed or post-processed. The parameter filling i
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 httpservletrequest instance and httpservletrespon
Interceptors are the struts2 core, and many functions are implemented by interceptors.
I. Write a interceptor yourself
Write the interception in the Interceptor method
two. Configuring Interceptors in Struts2.xml
Write the
Note:
The interceptor in the STRUTS2 is similar to the servlet filter, but the Struts2
In the previous article, we introduced how to use unity to take over piab for interception, while Unity itself also provides interception processing similar to icallhandler.Program-- Iinterceptionbehavior, today's articleArticleIt is mainly about how to use iinterceptionbehavior and the built-in interceptor of unity.
The following is what we will introduce:
1. Create a custom interceptionbehavior
2. Advantages and disadvantages of the thr
Turnhttp://www.cnblogs.com/wangyuyu/archive/2013/07/02/3167354.html1, interceptors are based on the reflection mechanism of Java, and filter is based on function callback2. The filter relies on the servlet container, while the interceptor does not depend on the servlet container3. Interceptors only work on action requests, while filters can work on almost all requests4. The interceptor can access the action
The first time using Struts2.3.20, the foreground page to the background value, how always prompt value is null, find half a day originally was the Struts configuration file action forgot to introduce the defaultstack interceptor, so even if the action of Everything ( Package parameters of getter and setter), or can not achieve the desired results.Use a custom interceptor to configure the action in the stru
1. Preface
It is not familiar to hear interceptors, especially in the servlet specification, where the concept of interceptors is fully applied. EJB3 also provides interceptor support, which is essentially a lightweight AOP implementation that allows the interceptor to pull away common logic from business methods in multiple business methods and implement it in interceptors for excellent code reuse
In the previous article, I wrote about my own MVC framework, and then I talked about plugins and interceptors!In dealing with some common logic it is best to encapsulate a plugin or interceptor so that it can be used directly in the future. In my framework, you can implement plug-ins or interceptors by inheriting the following abstract classes.1. Aspectinterceptor Abstract classAn AOP interceptor that handl
InterceptorSpeaking of Interceptor, I believe that familiar with Struts2 's children's shoes will not be unfamiliar, struts2 can customize the interceptor to carry out their own desired series of related work. And the interceptor we're talking about here are pretty much the same function.Nonsense not to say, directly to the code:The following is the Myinterceptor
The order in which the Servlet filter and Spring interceptor are executed
is the filter in order? How do we control the order in which filter is executed? Through Tomcat code analysis, the servlet is called after filter execution is complete, and if multiple filter controls the order of execution, the first thing to do is to configure a parameter in the Web.xml, like order, but find out, the servlet does not have this parameter. Try the configuration
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.