struts2小结

Struts2使用OGNL进行类型转换。提供基本和常用对象的转换器。
Struts2使用“ValueStack”技术,使taglib能够访问值而不需要把你的页面(view)和对象绑定起来。
Struts2支持通过拦截器堆栈(Interceptor Stacks)为每一个Action创建不同的生命周期。


temp:#ActionContext储存了整个访问周期中的request,session,application
1、FilterDispatcher的处理流程
   1、处理HttpServletRequest,如果思上传的请求,对request进行包装
   2、查找该请求路径是否有对应的Action,有的话把该路径包装成一个ActionMapping对象
      #ActionMapping对象中含有name,method,namespace,params,result等属性(holds the action mapping information)
   3、交给Dispatcher类的serviceAction(request, response,servletContext,mapping)方法处理

2、Dispatcher类的处理过程
   1、分别实例化几个储存request,session,application的信息的Map对象

3、Struts2中的拦截器
   DispatcherFilter拦截器
   ActionAutowiringInterceptor拦截器
   ParametersInterceptor拦截器
   ServletConfigInterceptor拦截器

4、几个辅助接口
   SessionAware-通过Map来提供对所有session属性的访问
   ServletRequestAware-提供对HttpServletRequest对象的访问
   RequestAware-通过Map来提供对所有request属性的访问
   ApplicationAware-通过Map来提供对所有application属性的访问
   ServletResponseAware-提供对HttpServletREsponse对象的访问
   ParameterAware-通过Map来提供所有request String和表单数据的访问
   PrincipalAware-提供对PrincipleProxy对象的访问;该对象实现了HttpServletRequest对象的有关pringcile和role的方法,但是它提供了一个   Proxy,因此所有的实现都是独立于Action的。
   ServletContextAware-提供对ServletContext对象的访问

5、struts2的扩展自定义拦截器
   自定义拦截器实现Interceptor接口或者继承AbstractInterceptor 
   ActionInvocation对象可以用来访问运行时环境,以及Action本身;上下文(包括了Web应用的请求参数,session参数,用户Local等);Action   的执行结果;还有那些调用Action的方法并判断Action是否已被调用。

6、缩小Action的配置文件的牛X配置
   前提:struts.enable.SlashesInActionNames = true;
   URL模式:/{module}/{entity}/{action}.action
   配置文件:
   <action name="*/*/*" method="{3}" class="com.infoq.action.{1}.{2}action">
     <result name="view">/{1}/update{2}/jsp</result>
     <result name="list">/{1}/list{2}.jsp</result>
   </action>
   使用超强通配符

转自:http://blog.csdn.net/shmily2038/archive/2010/01/02/5120606.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值