Struts 2的拦截器原理和核心
来源:互联网 发布:php 字符串比较 编辑:程序博客网 时间:2024/06/05 04:33
Struts 2的拦截器原理
拦截器(Interceptor)是Struts 2的核心组成部分。很多功能(Feature)都是构建在拦截器基础之上的,例如文件的上传和下载、国际化、转换器和数据校验等,Struts 2利用内建的拦截器,完成了框架内的大部分操作。
在Struts 2文档中对拦截器的解释为——拦截器是动态拦截Action调用的对象。它提供了一种机制,使开发者可以定义一个特定的功能模块,这个模块可以在Action执行之前或者之后运行,也可以在一个Action执行之前阻止Action执行。同时也提供了一种可以提取Action中可重用的部分的方式。
5.2 Struts 2拦截器
通过上一节的介绍,读者会对拦截器的原理有了一个基本的理解,本节来介绍Struts 2架构中的拦截器。
5.2.1 Struts 2拦截器原理
读者可以通过Struts 2官方文档说明来理解拦截器,如果读者具有较强的英文阅读能力,建议查阅官方使用文档(http://struts.apache.org/2.0.11/docs/interceptors.html)。如图5.4所示,是拦截器在Struts 2中的示意图。
图5.4 Struts 2拦截器
从图5.4所示内容中可以看出,Struts 2架构的Action被一个或者多个拦截器(拦截器栈)所包围,所有的用户请求都会被拦截器所拦截,然后交给Action处理,处理结果以逻辑视图方式返回给用户。而这个调用执行流程,是由Struts 2的配置文件来实现的,后面会详细介绍。拦截器是Struts 2核心部分之一。
当用户请求到达Struts 2的ServletDispatcher时,Struts 2会查找配置文件,并根据其配置实例化相对的拦截器对象,然后串成一个列表(List),最后一个一个地调用列表中的拦截器。拦截器时序图如图5.5所示。
图5.5 Struts 2拦截器时序图
在Struts 2架构中,Action的调用都是通过拦截器来实现的。有的读者可能会疑惑,前几章的介绍中,没有明确说明拦截器,为什么可以直接调用Action?那是因为Struts 2架构如果不做显式的拦截器配置,则系统会调用默认的拦截器来调用Action,在用户看来,好像没有配置拦截器。系统默认的拦截器笔者后面会详细介绍。
5.2.2 HelloWorld拦截器
读者可以按照笔者的步骤,一步一步建立第一个拦截器示例,来体验Struts 2框架中拦截器带给读者的惊喜。
(1) 在配置文件中增加拦截器定义和在Action中声明拦截器。笔者建立了一个目录ch5来对应本章,ch5.xml配置文件内容如代码5.8所示。
代码5.8 HelloWorld拦截器配置文件
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 定义包-->
<package name="ch5" extends="struts-default" namespace="/ch5">
<!-- 定义拦截器-->
<interceptors>
<interceptor name="Myinterceptor"
class="ch5.Myintercepor">
</interceptor>
</interceptors>
<action name="Reg" class="ch5.Reg">
<result name="success">/ch5/success.jsp</result>
<result name="input">/ch5/reg.jsp</result>
<!-- 引用默认拦截器-->
<interceptor-ref name="defaultStack"></interceptor-ref>
<!-- 引用自定义默认拦截器-->
<interceptor-ref name="Myinterceptor"></interceptor-ref>
</action>
</package>
</struts>
★ 注意 ★
需要读者在struts.xml文件中使用<include file="/ch5/ch5.xml"></include>将该配置文件包含进去。
(2)在ch5包内建立一个拦截器类Myintercepor,如代码5.9所示。
代码5.9 Helloworld拦截器类Myintercepor
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class Myintercepor extends AbstractInterceptor ...{
//拦截方法
public String intercept(ActionInvocation arg0) throws Exception ...{
Reg reg = (Reg) arg0.getAction();
System.out.println("拦截器信息:HelloWorld拦截器!");
//执行Action或者执行下一个拦截器
String result = arg0.invoke();
//提示Action执行完毕
System.out.println("拦截器信息:Action执行完毕!");
return result;
}
}
(3)在ch5包内建立一个业务控制器Reg,如代码5.10所示。
代码5.10 HelloWorld拦截器示例的业务控制器
import java.util.Date;
import com.opensymphony.xwork2.ActionSupport;
public class Reg extends ActionSupport ...{
//定义用户名属性
private String username;
//定义处理信息:注意同http中的msg不同名称
private String mymsg;
//定义密码属性
private String password1;
//定义确认密码
private String password2;
//定义生日属性
private Date birthday;
public String execute() throws Exception ...{
if (username != null && getPassword1().equals(getPassword2())
&& !getUsername().trim().equals("")) ...{
//输出调试信息
System.out.println("Action信息:正在执行Actiion... ...");
return SUCCESS;
} else ...{
return INPUT;
}
}
//getter和setter方法
public String getUsername() ...{
return username;
}
public void setUsername(String username) ...{
this.username = username;
}
public String getMymsg() ...{
return mymsg;
}
public void setMymsg(String mymsg) ...{
this.mymsg = mymsg;
}
public String getPassword1() ...{
return password1;
}
public void setPassword1(String password1) ...{
this.password1 = password1;
}
public String getPassword2() ...{
return password2;
}
public void setPassword2(String password2) ...{
this.password2 = password2;
}
public Date getBirthday() ...{
return birthday;
}
public void setBirthday(Date birthday) ...{
this.birthday = birthday;
}
}
(4)同样在ch5包内,建立一个用户注册reg.jsp文件和一个用于显示注册成功信息的success.jsp文件。内容分别如代码5.11和代码5.12所示。
代码5.11 用户注册界面reg.jsp
<%...@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>用户注册</title>
<s:head />
</head>
<body>
<table>
<s:form id="id" action="Reg">
<s:textfield name="username" label="用户名:"/>
<s:password name="password1" label="密码:"/>
<s:password name="password2" label="确认密码:"/>
<s:datetimepicker name="birthday" label="生日:"/>
<s:submit value="注册"/>
</s:form>
</table>
</body>
</html>
代码5.12 注册成功界面success.jsp
<%...@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>注册成功界面</title>
<s:head />
</head>
<body>
<table>
<h2>用户名:<s:property value="username" /></h2>
<h2>密码:<s:property value="password1" /></h2>
<h2>生日:<s:property value="birthday" /></h2>
</table>
</body>
</html>
(5) 启动Tomcat服务器,在浏览器中输入:http://localhost:8080/bookcode/ch5/reg.jsp,运行界面如图5.6所示。
图5.6 HelloWorld拦截器的注册界面
(6)读者可以在“用户名”、“密码”、“确认密码”和“生日”输入框中填入相关字符串,单击“注册”按钮,会发现Tomcat控制台输出如下信息:
… …
信息: Detected AnnotationActionValidatorManager, initializing it...
拦截器信息:HelloWorld拦截器!
Action信息:正在执行Actiion... ...
拦截器信息:Action执行完毕!
… …
到此为止,第一个拦截器HelloWorld示例就建立成功了,读者通过本示例,可以了解拦截器的基本功能。
这部分从Struts2参考文档中翻译就可以了。
ActionMapper
ActionMapper其实是HttpServletRequest和Action调用请求的一个映射,它屏蔽了Action对于Request等java Servlet类的依赖。Struts2中它的默认实现类是DefaultActionMapper,ActionMapper很大的用处可以根据自己的需要来设计url格式,它自己也有Restful的实现,具体可以参考文档的docs/actionmapper.html。
ActionProxy&ActionInvocation
Action的一个代理,由ActionProxyFactory创建,它本身不包括Action实例,默认实现DefaultActionProxy是由ActionInvocation持有Action实例。ActionProxy作用是如何取得Action,无论是本地还是远程。而ActionInvocation的作用是如何执行Action,拦截器的功能就是在ActionInvocation中实现的。
ConfigurationProvider&Configuration
ConfigurationProvider就是Struts2中配置文件的解析器,Struts2中的配置文件主要是尤其实现类XmlConfigurationProvider及其子类StrutsXmlConfigurationProvider来解析。
3. Struts2请求流程
1、客户端发送请求
2、请求先通过ActionContextCleanUp-->FilterDispatcher
3、FilterDispatcher通过ActionMapper来决定这个Request需要调用哪个Action
4、如果ActionMapper决定调用某个Action,FilterDispatcher把请求的处理交给ActionProxy,这儿已经转到它的Delegate--Dispatcher来执行
5、ActionProxy根据ActionMapping和ConfigurationManager找到需要调用的Action类
6、ActionProxy创建一个ActionInvocation的实例
7、ActionInvocation调用真正的Action,当然这涉及到相关拦截器的调用
8、Action执行完毕,ActionInvocation创建Result并返回,当然,如果要在返回之前做些什么,可以实现PreResultListener。添加PreResultListener可以在Interceptor中实现。
另一个版本:大同小异~
一个请求在Struts2框架中的处理大概分为以下几个步骤:
1.客户端提起一个(HttpServletRequest)请求,如上文在浏览器中输入”http://localhost:8080/TestMvc/add.action”就是提起一个(HttpServletRequest)请求。
2.请求被提交到一系列(主要是三层)的过滤器(Filter),如(ActionContextCleanUp、其他过滤器(SiteMesh等)、 FilterDispatcher)。注意这里是有顺序的,先ActionContextCleanUp,再其他过滤器(SiteMesh等)、最后到FilterDispatcher。
3.FilterDispatcher是控制器的核心,就是mvc中c控制层的核心。下面粗略的分析下我理解的FilterDispatcher工作流程和原理:FilterDispatcher进行初始化并启用核心doFilter
其代码如下:
- public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException ...{
- HttpServletRequest request = (HttpServletRequest) req;
- HttpServletResponse response = (HttpServletResponse) res;
- ServletContext servletContext = filterConfig.getServletContext();
- // 在这里处理了HttpServletRequest和HttpServletResponse。
- DispatcherUtils du = DispatcherUtils.getInstance();
- du.prepare(request, response);//正如这个方法名字一样进行locale、encoding以及特殊request parameters设置
- try ...{
- request = du.wrapRequest(request, servletContext);//对request进行包装
- } catch (IOException e) ...{
- String message = "Could not wrap servlet request with MultipartRequestWrapper!";
- LOG.error(message, e);
- throw new ServletException(message, e);
- }
- ActionMapperIF mapper = ActionMapperFactory.getMapper();//得到action的mapper
- ActionMapping mapping = mapper.getMapping(request);// 得到action 的 mapping
- if (mapping == null) ...{
- // there is no action in this request, should we look for a static resource?
- String resourcePath = RequestUtils.getServletPath(request);
- if ("".equals(resourcePath) && null != request.getPathInfo()) ...{
- resourcePath = request.getPathInfo();
- }
- if ("true".equals(Configuration.get(WebWorkConstants.WEBWORK_SERVE_STATIC_CONTENT))
- && resourcePath.startsWith("/webwork")) ...{
- String name = resourcePath.substring("/webwork".length());
- findStaticResource(name, response);
- } else ...{
- // this is a normal request, let it pass through
- chain.doFilter(request, response);
- }
- // WW did its job here
- return;
- }
- Object o = null;
- try ...{
- //setupContainer(request);
- o = beforeActionInvocation(request, servletContext);
- //整个框架最最核心的方法,下面分析
- du.serviceAction(request, response, servletContext, mapping);
- } finally ...{
- afterActionInvocation(request, servletContext, o);
- ActionContext.setContext(null);
- }
- }
- du.serviceAction(request, response, servletContext, mapping);
- //这个方法询问ActionMapper是否需要调用某个Action来处理这个(request)请求,如果ActionMapper决定需要调用某个Action,FilterDispatcher把请求的处理交给ActionProxy
- public void serviceAction(HttpServletRequest request, HttpServletResponse response, String namespace, String actionName, Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap) ...{
- HashMap extraContext = createContextMap(requestMap, parameterMap, sessionMap, applicationMap, request, response, getServletConfig()); //实例化Map请求 ,询问ActionMapper是否需要调用某个Action来处理这个(request)请求
- extraContext.put(SERVLET_DISPATCHER, this);
- OgnlValueStack stack = (OgnlValueStack) request.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY);
- if (stack != null) ...{
- extraContext.put(ActionContext.VALUE_STACK,new OgnlValueStack(stack));
- }
- try ...{
- ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext);
- //这里actionName是通过两道getActionName解析出来的, FilterDispatcher把请求的处理交给ActionProxy,下面是ServletDispatcher的 TODO:
- request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, proxy.getInvocation().getStack());
- proxy.execute();
- //通过代理模式执行ActionProxy
- if (stack != null)...{
- request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,stack);
- }
- } catch (ConfigurationException e) ...{
- log.error("Could not find action", e);
- sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e);
- } catch (Exception e) ...{
- log.error("Could not execute action", e);
- sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
- }
- }
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException ...{ HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; ServletContext servletContext = filterConfig.getServletContext(); // 在这里处理了HttpServletRequest和HttpServletResponse。 DispatcherUtils du = DispatcherUtils.getInstance(); du.prepare(request, response);//正如这个方法名字一样进行locale、encoding以及特殊request parameters设置 try ...{ request = du.wrapRequest(request, servletContext);//对request进行包装 } catch (IOException e) ...{ String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); } ActionMapperIF mapper = ActionMapperFactory.getMapper();//得到action的mapper ActionMapping mapping = mapper.getMapping(request);// 得到action 的 mapping if (mapping == null) ...{ // there is no action in this request, should we look for a static resource? String resourcePath = RequestUtils.getServletPath(request); if ("".equals(resourcePath) && null != request.getPathInfo()) ...{ resourcePath = request.getPathInfo(); } if ("true".equals(Configuration.get(WebWorkConstants.WEBWORK_SERVE_STATIC_CONTENT)) && resourcePath.startsWith("/webwork")) ...{ String name = resourcePath.substring("/webwork".length()); findStaticResource(name, response); } else ...{ // this is a normal request, let it pass through chain.doFilter(request, response); } // WW did its job here return; } Object o = null; try ...{ //setupContainer(request); o = beforeActionInvocation(request, servletContext); //整个框架最最核心的方法,下面分析 du.serviceAction(request, response, servletContext, mapping); } finally ...{ afterActionInvocation(request, servletContext, o); ActionContext.setContext(null); } } du.serviceAction(request, response, servletContext, mapping); //这个方法询问ActionMapper是否需要调用某个Action来处理这个(request)请求,如果ActionMapper决定需要调用某个Action,FilterDispatcher把请求的处理交给ActionProxy public void serviceAction(HttpServletRequest request, HttpServletResponse response, String namespace, String actionName, Map requestMap, Map parameterMap, Map sessionMap, Map applicationMap) ...{ HashMap extraContext = createContextMap(requestMap, parameterMap, sessionMap, applicationMap, request, response, getServletConfig()); //实例化Map请求 ,询问ActionMapper是否需要调用某个Action来处理这个(request)请求 extraContext.put(SERVLET_DISPATCHER, this); OgnlValueStack stack = (OgnlValueStack) request.getAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY); if (stack != null) ...{ extraContext.put(ActionContext.VALUE_STACK,new OgnlValueStack(stack)); } try ...{ ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy(namespace, actionName, extraContext); //这里actionName是通过两道getActionName解析出来的, FilterDispatcher把请求的处理交给ActionProxy,下面是ServletDispatcher的 TODO: request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY, proxy.getInvocation().getStack()); proxy.execute(); //通过代理模式执行ActionProxy if (stack != null)...{ request.setAttribute(ServletActionContext.WEBWORK_VALUESTACK_KEY,stack); } } catch (ConfigurationException e) ...{ log.error("Could not find action", e); sendError(request, response, HttpServletResponse.SC_NOT_FOUND, e); } catch (Exception e) ...{ log.error("Could not execute action", e); sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e); } }
4.FilterDispatcher询问ActionMapper是否需要调用某个Action来处理这个(request)请求,如果ActionMapper决定需要调用某个Action,FilterDispatcher把请求的处理交给ActionProxy。
5.ActionProxy通过Configuration Manager(struts.xml)询问框架的配置文件,找到需要调用的Action类.
如上文的struts.xml配置
- <?xml version="1.0" encoding="GBK"?>
- <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <include file="struts-default.xml"/>
- <package name="struts2" extends="struts-default">
- <action name="add"
- class="edisundong.AddAction" >
- <result>add.jsp</result>
- </action>
- </package>
- </struts>
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml"/> <package name="struts2" extends="struts-default"> <action name="add" class="edisundong.AddAction" > <result>add.jsp</result> </action> </package> </struts>
如果提交请求的是add.action,那么找到的Action类就是edisundong.AddAction。
6.ActionProxy创建一个ActionInvocation的实例,同时ActionInvocation通过代理模式调用Action。但在调用之前ActionInvocation会根据配置加载Action相关的所有Interceptor。(Interceptor是struts2另一个核心级的概念)
下面我们来看看ActionInvocation是如何工作的:
ActionInvocation 是Xworks 中Action 调度的核心。而对Interceptor 的调度,也正是由ActionInvocation负责。ActionInvocation 是一个接口, 而DefaultActionInvocation 则是Webwork 对ActionInvocation的默认实现。
Interceptor 的调度流程大致如下:
1. ActionInvocation初始化时,根据配置,加载Action相关的所有Interceptor。
2. 通过ActionInvocation.invoke方法调用Action实现时,执行Interceptor。
Interceptor将很多功能从我们的Action中独立出来,大量减少了我们Action的代码,独立出来的行为具有很好的重用性。XWork、WebWork的许多功能都是有Interceptor实现,可以在配置文件中组装Action用到的Interceptor,它会按照你指定的顺序,在Action执行前后运行。
那么什么是拦截器。
拦截器就是AOP(Aspect-Oriented Programming)的一种实现。(AOP是指用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作。)
拦截器的例子这里就不展开了。
struts-default.xml文件摘取的内容:
- < interceptor name ="alias" class ="com.opensymphony.xwork2.interceptor.AliasInterceptor" />
- < interceptor name ="autowiring" class ="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor" />
- < interceptor name ="chain" class ="com.opensymphony.xwork2.interceptor.ChainingInterceptor" />
- < interceptor name ="conversionError" class ="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor" />
- < interceptor name ="createSession" class ="org.apache.struts2.interceptor.CreateSessionInterceptor" />
- < interceptor name ="debugging" class ="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" />
- < interceptor name ="external-ref" class ="com.opensymphony.xwork2.interceptor.ExternalReferencesInterceptor" />
- < interceptor name ="execAndWait" class ="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor" />
- < interceptor name ="exception" class ="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor" />
- < interceptor name ="fileUpload" class ="org.apache.struts2.interceptor.FileUploadInterceptor" />
- < interceptor name ="i18n" class ="com.opensymphony.xwork2.interceptor.I18nInterceptor" />
- < interceptor name ="logger" class ="com.opensymphony.xwork2.interceptor.LoggingInterceptor" />
- < interceptor name ="model-driven" class ="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor" />
- < interceptor name ="scoped-model-driven" class ="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor" />
- < interceptor name ="params" class ="com.opensymphony.xwork2.interceptor.ParametersInterceptor" />
- < interceptor name ="prepare" class ="com.opensymphony.xwork2.interceptor.PrepareInterceptor" />
- < interceptor name ="static-params" class ="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor" />
- < interceptor name ="scope" class ="org.apache.struts2.interceptor.ScopeInterceptor" />
- < interceptor name ="servlet-config" class ="org.apache.struts2.interceptor.ServletConfigInterceptor" />
- < interceptor name ="sessionAutowiring" class ="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor" />
- < interceptor name ="timer" class ="com.opensymphony.xwork2.interceptor.TimerInterceptor" />
- < interceptor name ="token" class ="org.apache.struts2.interceptor.TokenInterceptor" />
- < interceptor name ="token-session" class ="org.apache.struts2.interceptor.TokenSessionStoreInterceptor" />
- < interceptor name ="validation" class ="com.opensymphony.xwork2.validator.ValidationInterceptor" />
- < interceptor name ="workflow" class ="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor" />
- < interceptor name ="store" class ="org.apache.struts2.interceptor.MessageStoreInterceptor" />
- < interceptor name ="checkbox" class ="org.apache.struts2.interceptor.CheckboxInterceptor" />
- < interceptor name ="profiling" class ="org.apache.struts2.interceptor.ProfilingActivationInterceptor" />
< interceptor name ="alias" class ="com.opensymphony.xwork2.interceptor.AliasInterceptor" /> < interceptor name ="autowiring" class ="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor" /> < interceptor name ="chain" class ="com.opensymphony.xwork2.interceptor.ChainingInterceptor" /> < interceptor name ="conversionError" class ="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor" /> < interceptor name ="createSession" class ="org.apache.struts2.interceptor.CreateSessionInterceptor" /> < interceptor name ="debugging" class ="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" /> < interceptor name ="external-ref" class ="com.opensymphony.xwork2.interceptor.ExternalReferencesInterceptor" /> < interceptor name ="execAndWait" class ="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor" /> < interceptor name ="exception" class ="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor" /> < interceptor name ="fileUpload" class ="org.apache.struts2.interceptor.FileUploadInterceptor" /> < interceptor name ="i18n" class ="com.opensymphony.xwork2.interceptor.I18nInterceptor" /> < interceptor name ="logger" class ="com.opensymphony.xwork2.interceptor.LoggingInterceptor" /> < interceptor name ="model-driven" class ="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor" /> < interceptor name ="scoped-model-driven" class ="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor" /> < interceptor name ="params" class ="com.opensymphony.xwork2.interceptor.ParametersInterceptor" /> < interceptor name ="prepare" class ="com.opensymphony.xwork2.interceptor.PrepareInterceptor" /> < interceptor name ="static-params" class ="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor" /> < interceptor name ="scope" class ="org.apache.struts2.interceptor.ScopeInterceptor" /> < interceptor name ="servlet-config" class ="org.apache.struts2.interceptor.ServletConfigInterceptor" /> < interceptor name ="sessionAutowiring" class ="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor" /> < interceptor name ="timer" class ="com.opensymphony.xwork2.interceptor.TimerInterceptor" /> < interceptor name ="token" class ="org.apache.struts2.interceptor.TokenInterceptor" /> < interceptor name ="token-session" class ="org.apache.struts2.interceptor.TokenSessionStoreInterceptor" /> < interceptor name ="validation" class ="com.opensymphony.xwork2.validator.ValidationInterceptor" /> < interceptor name ="workflow" class ="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor" /> < interceptor name ="store" class ="org.apache.struts2.interceptor.MessageStoreInterceptor" /> < interceptor name ="checkbox" class ="org.apache.struts2.interceptor.CheckboxInterceptor" /> < interceptor name ="profiling" class ="org.apache.struts2.interceptor.ProfilingActivationInterceptor" />
7.一旦Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。如上文中将结构返回“add.jsp”,但大部分时候都是返回另外一个action,那么流程又得走一遍………
- Struts 2的拦截器原理和核心
- Struts 2的拦截器原理
- struts 拦截器和过滤器的区别和原理
- struts核心拦截器(5)
- struts核心拦截器(6)
- struts拦截器原理
- struts拦截器的原理与实现
- 关于Struts 2 拦截器参数丢失问题 ,拦截器原理和实现
- Struts 2的拦截器
- struts核心:拦截器(03-31)
- filter 和 struts 拦截器的区别
- Struts拦截器和过滤器的区别
- struts2核心与拦截器的原理解析
- struts 的拦截器
- struts的拦截器
- Struts 2 拦截器底层实现原理 学习笔记
- Struts 2拦截器
- Struts 2拦截器
- for loop initial declaration used outside C99 mode
- Ajax收缩级联菜单(实例)
- How to remove an ASM instance and its corresponding database(s) on WINDOWS
- pthread_cond_wait的工作机制
- Die young at 80
- Struts 2的拦截器原理和核心
- How to remove an ASM instance and its corresponding database(s) on UNIX
- 镜之边缘第四关破解补丁TlsGetValue 导致的Bug解决方法
- HTTP协议及其POST与GET操作差异 & C#中如何使用POST、GET等
- QQ农场耕种计划
- 一个多线程实例
- poj 1782
- 预防数据库攻击的PHP函数一例子 mysql_real_escape_string()
- 表达式计算器(MFC)