美文网首页
struts2拦截器配置

struts2拦截器配置

作者: playman | 来源:发表于2018-06-24 22:07 被阅读0次

拦截器

基本配置

struts.xml中
name:自定义拦截器的名称
class:拦截器所在的类
<interceptor name="myInterceptor" class="com.ben.interceptor.MyInterceptor"></interceptor>
<action name="" class="">
    <interceptor-ref name="defaultStack"></interceptor-ref>
    <interceptor-ref name="myInterceptor"></interceptor-ref>
</action>
MyInterceptor.java
实现Interceptor接口,重写方法
package com.ben.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class MyInterceptor implements Interceptor{
    @Override
    public String intercept(ActionInvocation arg0) throws Exception {
        // TODO Auto-generated method stub
        return null;
    }
    @Override
    public void destroy() {
        // TODO Auto-generated method stub
    }
    @Override
    public void init() {
        // TODO Auto-generated method stub
    }
}

相关文章

网友评论

      本文标题:struts2拦截器配置

      本文链接:https://www.haomeiwen.com/subject/aynsyftx.html