使用struts配置拦截器
2017-02-06 13:46
344 查看
首先创建一个拦截器类:
然后配置struts.xml文件:
这样就完成了拦截器的配置
public class CustomInterceptor implements Interceptor { private static final long serialVersionUID = 1L; public void destroy() { } public void init() { } public String intercept(ActionInvocation invocation) throws Exception { if (invocation.getAction() instanceof BaseAction) { system.out.println("进入拦截器"); return invocation.invoke(); } else { return invocation.invoke(); } } }
然后配置struts.xml文件:
<package name="default" extends="struts-default"> <interceptors> <interceptor name="customInterceptor" class="com.test.utils.CustomInterceptor"></interceptor> </interceptors> </package>
这样就完成了拦截器的配置
相关文章推荐
- Struts2 拦截器的使用及配置
- Struts2国际化、拦截器配置以及使用struts上传文件
- struts拦截器配置和使用
- struts学习笔记之Struts标签的配置使用
- 使用Spring内置拦截器为Struts的Action在每个方法调用之前打印一句话
- struts2.0 Interceptor Configuration(拦截器配置)
- Struts 验证框架配置和使用
- 使用多个Struts配置文件
- struts 使用多个配置文件 struts-config.xml
- struts配置文件中的form定义中使用string[]的一点疑问
- struts 使用多个配置文件 struts-config.xml
- 在struts中使用拦截器(Interceptor)控制登录和权限
- struts的配置和使用
- 使用struts1.x开发配置
- JSP的那些事儿(7)----Struts 2.1.6的配置和使用
- 尚学堂Struts学习笔记1:Struts标签的配置和使用
- 使用Spring内置拦截器为Struts动作在每个方法调用之前打印一句话
- 使用多个Struts配置
- struts中数据源(DataSource)的配置与使用
- 在struts1.2中使用拦截器