struts2的拦截器Interceptor
来源:互联网 发布:cf网络异常23 2 编辑:程序博客网 时间:2024/05/17 09:14
package com.lanou.controller.interceptors;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class TestInterceptorimplements Interceptor{
@Override
public void destroy(){
}
@Override
public void init(){
}
//ActionInvocation可以帮助获得action对象
@Override
publicString intercept(ActionInvocationinvoc) throws Exception{
System.out.println("第二个开始拦截");
String str=invoc.invokeActionOnly();
System.out.println(str);
System.out.println("第二个拦截器内容是:"+str);
return"success";
}
struts.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPE strutsPUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- -->
<constantname="struts.enable.DynamicMethodInvocation"value="false"/>
<constantname="struts.devMode"value="true"/>
<packagename="default"namespace="/"extends="json-default">
<!-- 在学习servlet的时候,filter是通过url-pattern关联到一起的 -->
<!--filetr是通过配置文件配置进来的 -->
<!--拦截器interceptor也是通过配置文件进入系统的 ,执行过程123,321,先进入web.xml文件,在进入action,再进拦截器 -->
<interceptors>
<!-- 自定义拦截器实现Interceptor接口或实现AbstractInterceptor 类 -->
<interceptorname="test"
class="com.lanou.controller.interceptors.TestInterceptor"></interceptor>
<interceptorname="second"
class="com.lanou.controller.interceptors.SecondInterceptor"></interceptor>
<interceptor-stackname="yufei">
<interceptor-refname="second"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-refname="test"></interceptor-ref>
</interceptor-stack>
</interceptors>
<actionname="test"class="com.lanou.controller.actions.TestAction"
method="test">
<!-- -interceptor的配置过程在action标签里面 ,在没有action -->
<interceptor-refname="yufei"></interceptor-ref>
<resultname="success">
/test.html
</result>
</action>
</package>
<includefile="example.xml"/>
</struts>
}
- struts2的拦截器(Interceptor)
- Struts2的拦截器interceptor
- struts2的拦截器Interceptor
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- struts2 拦截器 interceptor
- struts2 拦截器 interceptor
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor)
- Struts2拦截器(Interceptor
- struts2 拦截器 interceptor
- Struts2拦截器(Interceptor)
- Protocol Buffer的C++入门教程
- 为什么需要黑苹果(hackintosh)
- linux Ubuntu 16.04 (二) 图形绘制
- SSH框架分层功能区分
- Unity地形导出为.obj模型
- struts2的拦截器Interceptor
- win10 chrome被毒霸2345劫持主页处理过程与结果
- 设置toolbar和系统状态栏颜色一致
- 我的常用命令
- 支付宝获取页面静态授权
- 约瑟夫问题
- 使用pullToRefresh进行下拉刷新和上拉加载
- 11 Container with Most Water
- AHOI 2005 洗牌