1, interceptors are based on the reflection mechanism of Java, filter is based on function callback2. Interceptors are not dependent on the servlet container, and the filter relies on the servlet container3. Interceptors can only work on action requests, and filters will work on almost all requests4. The interceptor can access the action context, the object in the value stack, and the filter cannot5, in the life cycle of the action, the
Since some of the most recent projects are interface remote invocation, using Access and business permissions to authenticate, the need to use SPRINGMVC interceptor, used to use Struts2 when the Interceptor, and the SPRINGMVC interceptor function has not been studied before, so this time to a little research, The concl
tamper with its return value by Filtercontext.result. Like this, I'm returning him a JSON .Jsonresult JSON=NewJsonresult (); Json. Data=New{status="1", message="OK"}; Json. Jsonrequestbehavior=Jsonrequestbehavior.allowget; Filtercontext.result=JSON; //Suppose we add a zone named admin to the MVC project, then add a home controller under the zone and add an index view. //So now we're going to go to the path to this view:http://localhost: 5219/admin/home/index//Get Zone vararea = Filte
1. ConceptThe Interceptor in Java is the object that dynamically intercepts action calls, and it provides a mechanism to enable a developer to execute a piece of code before and after an action executes, or to prevent it from executing before an action executes. It also provides a way to extract reusable portions of the code in an action. In AOP, interceptors are used to intercept a method or field before it is accessed, before or after a certain acti
/S2PLUGINS/jfreechart-plugin.html
Jasperreports Plugin: http://cwiki.apache.org/S2PLUGINS/jasperreports-plugin.html
Connext graph Plugin: http://cwiki.apache.org/S2PLUGINS/connext-graph-plugin.html
In the subsequent sections, I will select several representative in INS for detailed analysis and description. The extension points of struts2 show that many default behaviors of struts2 can be extended through p
Struts2 framework Learning (1), struts2 framework Learning
I. struts2 framework concept
The Struts2 framework is a lightweight MVC process framework. Lightweight refers to the process framework that supports hierarchical development because there are not many code programs and not many resources occupied during runtime
this action agent actually calls the action to process the request of the method will go through the Interceptor 1,2,3, before the actual call action method, the action method ends will return a view, The view will also refer to the actionmapping and refer to the template (Jsp,freemarker), at which point the interceptor will intercept again (stating that the STRUTS2
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
joins, we'll start with configuring the environment next. Many students may have such a question, why I submitted the request can go to Struts.xml to find the corresponding action. At least I had a question when I first started to study. Now the answer is for everyone, because the core of the struts2 is the interceptor, and all requests have to go through the intercept
Struts2 is a very good Web application framework that is elegant, powerful, and simple to use. It can be said that Struts2 is a very mature MVC architecture.
when we learn Struts2, it is better to learn its running process, the core concept, to be inspired, improve themselves, rather than learn how to use it.
first, the system architecture
. Interceptors only work on action requests, while filters can work on almost all requests.4. The interceptor can access the action context, the object in the value stack, and the filter cannot be accessed. 5. The interceptor can be called multiple times during the life cycle of the action, and the filter can only be called once when the container is initialized The code implementation of the
of interceptor comes from the idea of Spring AOP (for Aspect-Oriented Programming ).The interceptor adopts the responsibility chain mode.* In the responsibility chain mode, many objects are connected by each object's reference to its next home to form a chain.* Each node of the responsible chain can continue to call the next node or stop the process from being executed.In
can refactor the servlet to make it easier to develop. Easier and more suitable for teamwork.
The goal of refactoring:
1, only write a serlvet or filter, we choose the filter here.
2, no longer write any servlet, so the code written in the Web.xml is very little.
3), the original need to write Serlvet, now rewrite action.
4), in the action of the HttpServletRequest parameters and HttpServletResponse parameters passed past.
5, in the filter through the Java Reflection Mechanism invoke action.
3
, after adding the jar package, we will start to work with the configuration environment. Many may have such questions: why can I find the corresponding action in struts. xml when I submit a request ?? At least I had such a question when I first started learning. Now we can reveal the answer, because the core of struts2 is the interceptor, and all requests must be forwarded to the corresponding action throu
will be dispatcher initialization failed problem. It's probably the reason for the packet collision. Only copy the following nine jars in the past, the author's pro-Test can be successfully started the project.3, to the Web project, XML file to write the following code, the use of filters, not to say what page to intercept, meaning that all pages are required to implement STRUTS2 features, the role of the Interce
to the target object method, before the target object method is invoked, executes the Interceptor's before
() After the target object method is invoked, the After () of the interceptor is executed;There is also one of the most important proxy object myproxy, which has a getproxy () method that passes through the target object, where the target object is set into the processor
To Myhandler.setobject (object), and then returns a proxy instance that inv
The Interceptor is triggered when ajax initiates an action, and ajax initiates an action interception.
A problem occurred during project creation. When ajax initiates an action and triggers the interceptor, the returned value will not initiate a jump if it does not receive the same result, the pos form t can be used for submission.
After a long struggle, I have found a method that is not very scientific. I
Action chain) a template of JSP or FreeMarker to be represented. You can use the tag inherited from the Struts2 framework in the Process of representation.
Workflow: the process of a request in the Struts2 framework is roughly divided into the following steps: 1. the client sends a request;2. This request goes through a series of filters (these filters have an optional Filter called ActionContextCleanUp,
Struts2YesWebwork2The Foundation developed from. Like struts1, struts2 also belongsMVCFramework. However, it should be noted that, although the name differences between struts2 and struts1 are not very largeCodeThe writing style is almost different. So why should we release struts1?
Struts2. It is mainly because struts2
Preface
Interceptors are a core feature of the STRUTS2 framework, and understanding and using interceptors can help you use Struts2 more flexibly. Interceptors are somewhat similar to, but not identical to, the filters in the servlet. Because the interceptor is more like a pluggable component in Struts2, it is done aro
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.