62,620
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2" extends="struts-default">
<interceptors>
<interceptor name="myInterceptor3" class="com.test.interceptor.MyInterceptor3"></interceptor>
</interceptors>
<action name="register"
class="com.test.action.RegisterAction">
<result name="success">/success.jsp</result>
<result name="input">/register2.jsp</result>
<interceptor-ref name="myInterceptor3">
<param name="includeMethods">validate,execute</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>
</package>
</struts>
package com.test.action;
import java.util.Date;
import com.opensymphony.xwork2.ActionSupport;
public class RegisterAction2 extends ActionSupport {
/* 一些Bean的属性和方法(略) */
public String execute() throws Exception {
System.out.println("execute~~~~");
return SUCCESS;
}
public void validate() {
System.out.println("validate~~~");
}
}
package com.test.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
public class MyInterceptor3 extends MethodFilterInterceptor {
protected String doIntercept(ActionInvocation invocation) throws Exception {
System.out.println("MyInterceptor3");
System.out.println("My Interceptor3's method: "+invocation.getProxy().getMethod().toString());
String result=invocation.invoke();
return result;
}
}