struts拦截器
spring-security模块实现了权限控制功能.
自定义过滤器
1.自定义一个类实现Interceptor接口.
2.配置在调用的action中.并且加入默认的过滤器栈.只要你要使用默认的过滤器栈.
<interceptors> <interceptor name="auth" class="com.meiyoudao.filter.AuthFilter"></interceptor> </interceptors> <action name="welcome" class="com.meiyoudao.action.WelcomeAction"> <interceptor-ref name="auth"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> <result>/welcome.jsp</result> </action>
/** * */ package com.meiyoudao.filter; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; /** * @author meiyoudao * */ public class AuthFilter implements Interceptor { /* (non-Javadoc) * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy() */ public void destroy() { // TODO Auto-generated method stub } /* (non-Javadoc) * @see com.opensymphony.xwork2.interceptor.Interceptor#init() */ public void init() { // TODO Auto-generated method stub } /* (non-Javadoc) * @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation) */ public String intercept(ActionInvocation invocation) throws Exception { System.out.println("do something filter begin..."); String str = invocation.invoke(); System.out.println("do something filter end..."); return str; } }
相关推荐
凯哥Java 2020-07-04
smalllove 2020-03-27
HappyHeng 2020-02-01
melonjj 2020-01-04
smalllove 2019-12-21
秦怀卓 2019-11-12
Julywhj 2019-10-22
meleto 2019-09-07
burning 2019-01-25
industry0 2018-09-06
秦怀卓 2018-08-09
MayMatrix 2019-01-25
LeeEmmmm 2019-07-01
mowengaoboa 2018-08-09
HappyHeng 2017-01-03
binggege 2016-03-18
Julywhj 2015-06-24