您的位置:首页 > 编程语言 > Java开发

使用struts配置拦截器

2017-02-06 13:46 344 查看
首先创建一个拦截器类:

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>


这样就完成了拦截器的配置
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struts 拦截器