Struts2简介
Status2是一个基于MVC设计模式的Web应用模型,他本质就是Servlet,在MVC设计中,他作为控制器,来简历模型与视图的交互,Status2是Status1和WebWork的技术基础上进行了合并的全新框架。
Struts2的核心点
拦截器 interceptor
Action
ognl和valueStack
Struts2 执行流程
当浏览器发送一个请求
会被strutsPerpareAndExecuteFilter拦截
会调用struts默认的拦截器 interceptor
执行action中的操作
根据action的方法执行结果
StrutsPerpareAndExecuteFilter 一般叫做核心控制器
默认的拦截器,是在struts-default.xml中配置的 在struts-core.jar 中
<interceptor-stack name="defaultStack">
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="datetime"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params"/>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="debugging"/>
<interceptor-ref name="deprecation"/>
</interceptor-stack>
<!-- The completeStack is here for backwards compatibility for
applications that still refer to the defaultStack by the
old name -->
<interceptor-stack name="completeStack">
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
Struts框架配置文件的加载顺序
位置:前段过滤器中init(),有一个initDispatcher(),里面有init();
this.init_DefaultProperties(); [1]
this.init_TraditionalXmlConfigurations(); [2]
this.init_LegacyStrutsProperties(); [3]
this.init_CustomConfigurationProviders(); [5]
this.init_FilterInitParameters(); [6]
this.init_AliasStandardObjects(); [7]
Container container = this.init_PreloadConfiguration();
container.inject(this);
|
|