2.拦截器代码
Java代码
package interceptor.RequestInterceptor;
import java.util.Map;
import javax.servlet.http.HttpSession;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class RequestInterceptor extends AbstractInterceptor {
private static final long serialVersionUID = 3244973830196015811L;
private HttpSession session;
public void setSession(Map<String, Object> session) {
this.session = (HttpSession) session;
}
public String intercept(ActionInvocation aInvocation) throws Exception {
// 获取请求的action名称
String actionName = aInvocation.getInvocationContext().getName();
// 获取action后附带参数
Map parameters = aInvocation.getInvocationContext().getParameters();
return Action.SUCCESS;
}
}
在Struts2拦截器中获取请求action名称及参数
最新推荐文章于 2018-09-03 19:44:40 发布