在Struts2拦截器中获取请求action名称及参数
1.Interceptor配置
package interceptor.RequestInterceptor;import java.util.Map;import javax.servlet.http.HttpSession;import com.opensymphony.xwork2.Action;import com.opensymphony.xwork2.ActionSupport;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();if (hrefList.contains(requestName)) { String result = actionInvocation.invoke(); return result; } else { ActionSupport aSupport = (ActionSupport) actionInvocation.getAction(); aSupport.addActionMessage("不存在该页面!请返回"); return Action.ERROR; }}