What is the function comparison between struts2 interceptor and spring AOP Interceptor (security3?

Source: Internet
Author: User

1. Summary Struts2 is simply an interceptor stack or a series of interceptors. The default interceptor is used to process user requests, use OGNL, and form verification. The spring interceptor is mainly reflected in the transaction management of AOP. For example, the display of errors or exceptions logs is also achieved by configuring the spring log interceptor. As the name suggests, an interceptor intercepts some requests and processes them accordingly. In a broad sense, the interceptor of spring and struts2 works in the same way. But the functions are different. 2. In the ssh project, which of the struts interceptor, filter, and spring aop interceptor is called first depends on your web. how to configure xml first depends on the integration method you use when <filter> then <servlet> requests arrive at <servlet>. If action is created using Spring, spring is used first; the other is that action has a Spring factory reference, this has nothing to do with Spring. 3. What is the difference between spring's aop and struts2 interceptor? spring's AOP is a line-oriented implementation method and a dynamic proxy. You can check the dynamic proxy and reflection. the video is understood, however, Spring interceptor is widely applied in the framework mode. Struts interceptors are for Struts. For example, all SSH projects use AOP. If a simple STRUTS project uses the interceptor of Struts itself, the final effect of the two is the same; there is no difference for applications, but there are minor differences for the underlying implementation methods! The interceptor is an implementation of AOP. The struts2 interceptor uses the interceptor of xwork2! Spring's AOP is based on IoC, and its underlying architecture adopts a combination of dynamic proxy and CGLIB proxy. 4. AOP interceptor instance @ Aspect @ Component ("intercept ") public class Intercept {private Logger log = LoggerFactory. getLogger (CacheIntercept. class ); /*** intercept the action method under the package ** @ param pjp instance of the actual method * @ return the actual method or the return value of the process */@ Around ("execution (* package name. action (..)) ") public Object doAround (ProceedingJoinPoint pjp) throws Throwable {// obtain the actual method of blocking Object target = pjp. getTarget (); // obtain the class name String className = target. getClass (). getName (); log. debug ("Run doAround with class" + className); return pjp. proceed ();} is added to the configuration file: <context: annotation-config/> <context: component-scan base-package = "package name"/> <aop: aspectj-autoproxy/>

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.