97. 那么什么是拦截器。
98. 拦截器就是AOP(Aspect-Oriented Programming)的一种实现。(AOP是指用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作。)
99. 拦截器的例子这里就不展开了。
100. struts-default.xml文件摘取的内容:
101. < interceptor name ="alias" class ="com.opensymphony.xwork2.interceptor.AliasInterceptor" />
102. < interceptor name ="autowiring" class ="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor" />
103. < interceptor name ="chain" class ="com.opensymphony.xwork2.interceptor.ChainingInterceptor" />
104. < interceptor name ="conversionError" class ="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor" />
105. < interceptor name ="createSession" class ="org.apache.struts2.interceptor.CreateSessionInterceptor" />
106. < interceptor name ="debugging" class ="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" />
107. < interceptor name ="external-ref" class ="com.opensymphony.xwork2.interceptor.ExternalReferencesInterceptor" />
108. < interceptor name ="execAndWait" class ="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor" />
109. < interceptor name ="exception" class ="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor" />
110. < interceptor name ="fileUpload" class ="org.apache.struts2.interceptor.FileUploadInterceptor" />
111. < interceptor name ="i18n" class ="com.opensymphony.xwork2.interceptor.I18nInterceptor" />
112. < interceptor name ="logger" class ="com.opensymphony.xwork2.interceptor.LoggingInterceptor" />
113. < interceptor name ="model-driven" class ="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor" />
114. < interceptor name ="scoped-model-driven" class ="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor" />
115. < interceptor name ="params" class ="com.opensymphony.xwork2.interceptor.ParametersInterceptor" />
116. < interceptor name ="prepare" class ="com.opensymphony.xwork2.interceptor.PrepareInterceptor" />
117. < interceptor name ="static-params" class ="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor" />
118. < interceptor name ="scope" class ="org.apache.struts2.interceptor.ScopeInterceptor" />
119. < interceptor name ="servlet-config" class ="org.apache.struts2.interceptor.ServletConfigInterceptor" />
120. < interceptor name ="sessionAutowiring" class ="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor" />
121. < interceptor name ="timer" class ="com.opensymphony.xwork2.interceptor.TimerInterceptor" />
122. < interceptor name ="token" class ="org.apache.struts2.interceptor.TokenInterceptor" />
123. < interceptor name ="token-session" class ="org.apache.struts2.interceptor.TokenSessionStoreInterceptor" />
124. < interceptor name ="validation" class ="com.opensymphony.xwork2.validator.ValidationInterceptor" />
125. < interceptor name ="workflow" class ="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor" />
126. < interceptor name ="store" class ="org.apache.struts2.interceptor.MessageStoreInterceptor" />
127. < interceptor name ="checkbox" class ="org.apache.struts2.interceptor.CheckboxInterceptor" />
128. < interceptor name ="profiling" class ="org.apache.struts2.interceptor.ProfilingActivationInterceptor" />
一旦Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。如上文中将结构返回“add.jsp”,但大部分时候都是返回另外一个action,那么流程又得走一遍………
摘自 Tender