博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Struts2配置文件的详解
阅读量:6861 次
发布时间:2019-06-26

本文共 675 字,大约阅读时间需要 2 分钟。

hot3.png

1.struts2的拦截器:

拦截器分为自定义拦截器和struts2默认的拦截器

自定义拦截器的action:

1.继承 AbstractInterceptor

2.重写 intercept方法

3.在intercept方法中进行拦截操作

struts2默认的拦截器,直接引用

struts2的配置文件中如何引入拦截器

1.注册拦截器

<interceptors>

            <!-- 单个拦截器-->

            <interceptor name="myExceptionInterceptor"
                class="com.hq.tools.MyExceptionInterceptor">
            </interceptor>
            <!-- 拦截器栈 -->
            <interceptor-stack name="myStack">
                <interceptor-ref name="myExceptionInterceptor"></interceptor-ref>

                <!--引入默认的拦截器栈-->

                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>

</interceptors>

2.使用拦截器

<default-interceptor-ref name="myStack"></default-interceptor-ref>

3.该包下面的action在执行之前都进过这些拦截器

转载于:https://my.oschina.net/u/2870118/blog/800906

你可能感兴趣的文章
初步学习Django-第四篇:views.PY文件详解
查看>>
OAuth2简易实战(四)-Github社交联合登录
查看>>
Netty学习大纲
查看>>
OC中的私有方法
查看>>
分享几段JavaScript
查看>>
C++中的多态和Objective-C中的“多态”
查看>>
js基础五
查看>>
构建执法阅读笔记01
查看>>
剑指offer:合并两个排序的链表
查看>>
1602液晶显示实验
查看>>
图片水印
查看>>
Quart2D的基本介绍
查看>>
Lua点号和冒号区别
查看>>
STL基础
查看>>
有没有人要贪吃蛇的代码,然而有....................
查看>>
linux的top命令参数详解
查看>>
spring常用注解
查看>>
Material Menu
查看>>
Win8 环境变量位置
查看>>
margin负值的应用总结
查看>>