码迷,mamicode.com
首页 > 其他好文 > 详细

struts2 拦截器

时间:2019-05-03 16:31:50      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:sof   string   org   invoke   log   1.0   type   dex   login   

Stucts2 拦截器

public class InterceptorDemo1 extends AbstractInterceptor{

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		System.out.println("拦截前");
		String result = invocation.invoke();
		
		System.out.println("拦截 后");
		return result;
	}

}

  

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
	<package name="main" extends="struts-default">
		 <interceptors>
		<interceptor name="interceptorTest1" class="InterceptorDemo1" ></interceptor>
		<interceptor name="interceptorTest2" class="InterceptorDemo2" ></interceptor>
		<interceptor name="loginCheckInterceptor" class="LoginCheckInterceptor"></interceptor>
	   </interceptors> 
		<action name="MyAction" class="MyAction">
		<interceptor-ref name="interceptorTest1"></interceptor-ref>
			<interceptor-ref name="interceptorTest2"></interceptor-ref> 
			<result name="success">/index.jsp</result>
		</action>
		<action name="login" class="CustomerAction" method="login">
            <result>/login.jsp</result>
        </action>
		
	</package>
	
</struts>   

  

struts2 拦截器

标签:sof   string   org   invoke   log   1.0   type   dex   login   

原文地址:https://www.cnblogs.com/linlf03/p/5156969.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!