Struts2 Interceptor 拦截器的使用流程
来源:互联网 发布:股票提醒软件 换手率 编辑:程序博客网 时间:2024/06/06 02:27
struts.xml
<struts> <package name="default" namespace="/" extends="struts-default"> <!-- 自定义拦截器组合 --> <interceptors> <!-- 自定义拦截器 --> <interceptor name="my" class="com.tc.MyInterceptor"/> <!-- 自定义拦截器栈 --> <interceptor-stack name="myStack"> <interceptor-ref name="my"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </interceptor-stack> </interceptors> <!-- 以下两种为默认情况下所依赖的拦截器,根据不同情况酌情选择 --> <!-- 整个struts.xml都依赖于myStack拦截器栈 --> <default-interceptor-ref name="myStack"></default-interceptor-ref> <!-- 整个struts.xml都依赖于my拦截器 --> <!-- <default-interceptor-ref name="my"></default-interceptor-ref> --> <action name="add" class="com.tc.HelloWorld" method="add"> <!-- 可添加action的自定义拦截器 --> <interceptor-ref name="my"></interceptor-ref> <!-- 亦可添加action的自定义拦截器栈 --> <interceptor-ref name="myStack"></interceptor-ref> <result>/HelloWorld.jsp</result> </action> </package></struts>
拦截器类
/** * 自定义拦截器: * 实现implements Interceptor * 或者 * 继承extends AbstractInterceptor * @author TC * */public class MyInterceptor extends AbstractInterceptor{ /** * 拦截器销毁之前调用的方法 */ @Override public void destroy() { // TODO Auto-generated method stub System.out.println("destroy"); } /** * 拦截器处理之前,调用init方法初始化 */ @Override public void init() { // TODO Auto-generated method stub System.out.println("init"); } /** * 拦截器处理方法 */ @Override public String intercept(ActionInvocation invocation) throws Exception { // TODO Auto-generated method stub System.out.println("执行之前"); String result = invocation.invoke(); System.out.println("执行之后"); return result; }}
阅读全文
0 0
- 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)
- android异步更新UI
- 手写matlab的弗洛伊德算法的函数(注释很详细)
- [iOS sql数据库] 根据多个条件update数据
- bzoj3195[Jxoi2012]奇怪的道路 状压DP
- 判断 jqGrid表格加载返回数据是否为空
- Struts2 Interceptor 拦截器的使用流程
- MFC中点击文本框显示提示,点击其他地方提示消失的方法
- 11亿手机网民每天消耗5小时 中小企业移动营销怎么玩?
- Java学习之路
- Create and read table cotents in .doc file
- css超出文本隐藏
- hdu 6077 Time To Get Up【暴力】
- VS上配置opencv的路径
- NYOJ Binary String Matching的stl解法 酒馆浪人的博客