首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

在Struts1.x中施用net.sf.struts.saif.SAIFSpringPlugin配置Interceptor(拦截器)

2012-10-28 
在Struts1.x中使用net.sf.struts.saif.SAIFSpringPlugin配置Interceptor(拦截器)几个月前,Struts2发布,这

在Struts1.x中使用net.sf.struts.saif.SAIFSpringPlugin配置Interceptor(拦截器)
  几个月前,Struts2发布,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能。这是个非常有用的功能,可是struts1.x却没有。其实,struts1.x可以配合插件,实现拦截器的功能。
       SAIF(Struts Action Invocation Framework)是一个开源组件,它让Struts框架具备Action拦截器与IOC的功能,这样你的1.x框架也就有了拦截器的功能。
      就是添加拦截器的步骤:
      1.将saif.jar包放入你的lib中。
      2.创建Interceptor类。比如我在这里创建一个类:


3.写interceptor配置文件:interceptor-config.xml。这个配置文件中指定了interceptor类和要被拦截的action

4.在struts-config.xml中指定加载interceptor-config.xml

ok,配置完后,启动服务器,然后输入.../display.do?user_name=fred,回车,这时候,这个请求就会被拦截来,

进入beforeAction中,进行验证,若验证成功,return null,就会转到action的forward指向的页面,若不成功,

就会转向另一个页面。

http://hi.baidu.com/wmkoyo/blog/item/b4a65aa488570bf19152ee0c.html这个type的值该填什么呢?
我试了interceptor.DisplayInterceptor和cn.softjob.util.DisplayInterceptor还有你的
com.tlt.app.interceptor.LoginInterceptor
页面都是报Failed to create interceptor of type xxx(type值)这种错误。这个type的值该填什么呢?
我试了interceptor.DisplayInterceptor和cn.softjob.util.DisplayInterceptor还有你的
com.tlt.app.interceptor.LoginInterceptor
页面都是报Failed to create interceptor of type xxx(type值)这种错误。
type="interceptor.DisplayInterceptor" 是你拦截器的类名啊,要确保路径正确!了,谢谢你~~  </plug-in>

和你的不一样


热点排行