separate request processors (lifecycle) for each module, but all actions in the module must share the same lifecycle.• Struts2 supports creating different lifecycles for each action through interceptor stacks. The stack can be used with different actions as needed.
I. Introduction The first version of struts was released in July. Its initial idea was to clearly separate the view and Business/application lo
file in ActionSerlvet, and the latter loads it in the StrutsPrepareAndExecuteFilter filter. Therefore, unlike Struts1, We need to configure the Filter of Struts2 in web. xml to intercept requests. For the configuration method, see the preceding section.
2. Strtus2 core configuration fileThe default configuration file of Struts2 is struts. xml, which must be placed in the source code root directory. The act
http://localhost/test/a,
The container chooses the longest servlet in the path to match, which is the SERVLETB here.
extension Matching : If the last paragraph of the URL contains an extension, the container will select the appropriate servlet based on the extension.
Example: Servleta's Url-pattern:*.action
4.servlet,filter are all for URLs, and listener are for object manipulation, such as session creation, Session.setattribute, and doing something when such an event occurs.
Can be used f
not share an object with other requests, so there is no need to consider thread safety issues.
Interceptor Interceptor (The Interceptor) is used in AOP (aspect-oriented programming) to intercept a method or field before it is accessed, and then to add some action before or after.
Interception is an implementation strategy for AOP. The Chinese document in WebWork
constructor: Ctorf after pressing ENTER)Private ReadOnly Ibugservice _bugservice;Public Bugcontroller (Ibugservice bugservice){_bugservice = Bugservice;}}}Here are the tags that need to be filteredUsing System;Using System.Collections;Using System.Collections.Generic;Using System.Linq;Using SYSTEM.WEB.MVC;Using Microsoft.Practices.ServiceLocation;Using SaaS.Contracts.SaaS.Intern;Using SaaS.Framework.IIdentity;Using SaaS.Models.Domain.Enums;Namespace SaaS.Admin.Base{Base Controller[Customerfilte
consider thread safety issues.
Interceptor Interceptor (The Interceptor) is used in AOP (aspect-oriented programming) to intercept a method or field before it is accessed, and then to add some action before or after.
Interception is an implementation strategy for AOP. The Chinese document in WebWork is interpreted as-the int
1) The difference between servlet and filter
Filter can be considered as a "variant" of the servlet, which is mainly used to preprocess user requests or post-process httpservletresponse, which is a typical processing chain. It differs from the servlet in that it cannot generate a response directly to the user. The complete process is that the filter pre-processes the user request, then gives the request to the servlet for processing and generates a response, and finally the filter then processes
HTML response:Update of request model: send form to BackgroundSend user input to ControllerStruts2 Work FlowThe processing of a request in the STRUTS2 framework is roughly divided into the following steps:
Client initiated a (HttpServletRequest) request
The request is submitted to a series (mainly three layers) of filters (filter), such as Actioncontextcleanup, other filters, Sitemesh, etc., Filterdispatcher. Note that there are sequenti
following aftercompletion The Interceptor method can only be called if the return value of the Prehandle method of the currently-owned class is true. The Posthandle method, as the name implies, is executed after the current request is processed, that is, after the controller method call, but it is called before the view returns to render Dispatcherservlet. So we can manipulate the Modelandview object after controller processing in this method. The Po
[Mybatis] 1. Mybatis interceptor and mybatis interceptorPrinciple of MyBatis interceptor
Http://www.cnblogs.com/fangjian0423/p/mybatis-interceptor.htmlMyBatis Interceptor (implement paging function)
Http://www.cnblogs.com/jethypc/p/5149183.htmlThe principle of implementing the Interceptor (plug-in) through dynamic pr
This article is mainly about the handling of interceptors, here is the next org.springframework.web.servlet under the HandlerinterceptorJava InterceptorLook at the code through the Handlerinterceptor class Public Interface handlerinterceptor { booleanthrows Exception; void throws Exception; void throws Exception;}Interceptor processing is in, three methods of the meaning of a look to understand, do not do too much introductionSo what do we
Original,That's how we configured the Interceptor. The original configuration method combined with the new namespace mvc:interceptors configuration :Is that right???Because There's another one here that leads to no opensessioninviewinterceptor, no session . Exception So: Discard the original interceptor configuration to embrace the new method: Spring Original In
classIoCForStruts2ImplementsServletrequestaware {PrivateHttpServletRequest request; Public voidsetservletrequest (HttpServletRequest request) { This. Request =request;} PublicString Execute ()throwsException {//you can start working with the request object returnaction.success;}}It seems that these attributes are class-level, not thread-safe, and there are problems.In fact, there is no problem in Struts2, because each request comes up w
function can be used to keep the process going in the original way or lead the process. The servlet function is mainly used to lead the process.Filters can be used to filter character encoding, check whether users are logged in to filter, and disable page caching.3. servlet and filter are for URLs and the listener is for object operations, such as session creation and session. setattribute occurs when such an event occurs.It can be used for: Spring integrates struts, injects attributes into str
Spring interceptor (interceptor) Introduction, springinterceptor
1. interceptor Purpose
(1) intercept Unlogged users to directly access some links
(2) Intercepted log information
(3) Blocking illegal attacks, such as SQL Injection
2. jar and class
(1) spring-webmvc.jar
(2) HandlerInterceptor (org. springframework. web. servlet: Interface ),
AsyncHandlerIntercepto
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
HttpServletRequest request;public void Setservletrequest (HttpServletRequest request) {This.request = Request; }Public String Execute () throws Exception {You can start working with the Request objectreturn action.success; }}It seems that these attributes are class-level, not thread-safe, and there are problems.In fact, there is no problem in Struts2, because each request comes up with a new action object instance that does not share an object with o
. opensymphony. the role of the xwork2.ActionSupport;/*** class: *** @ author yiye banzhou * @ version 1.0 * @ Creation Time: 05:18:16 */public class MainAction extends ActionSupport {private static final long serialVersionUID = 1L; public String execute () throws Exception {return SUCCESS ;}}
7. interceptor. xml configuration file (this should be included in the struts. xml file with include)
Note: Only one default
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.