判断登陆权限的操作,登录后调到之前所操作的地址。

来源:互联网 发布:日本it公司 编辑:程序博客网 时间:2024/06/06 09:41
package com.framework.struts2.interceptor;import java.util.Map;import org.apache.log4j.Logger;import org.apache.struts2.dispatcher.ServletDispatcherResult;import com.opensymphony.xwork2.ActionInvocation;import com.opensymphony.xwork2.Result;import com.opensymphony.xwork2.interceptor.Interceptor;/*** @author wangbin**/@SuppressWarnings("serial")public class LoggerInterceptor implements Interceptor{private static final Logger logger = Logger.getLogger(LoggerInterceptor.class);@Overridepublic void destroy() {}@Overridepublic void init() {}@SuppressWarnings("unchecked")@Overridepublic String intercept(ActionInvocation invocation) throws Exception {logger.debug("Action:\t"+invocation.getAction().getClass().getName());logger.debug("Params:");//这个对象就是request.parametersMap<String, Object> parameters = invocation.getInvocationContext().getParameters();for (String key:parameters.keySet()){String[] params = (String[]) parameters.get(key);StringBuffer buffer = new StringBuffer();for (String param:params){buffer.append(","+param);}String paramValue = buffer.toString();paramValue = paramValue.substring(1);System.out.println(key+","+paramValue);}final String resultCode = invocation.invoke();Result realResult = invocation.getResult();if (realResult instanceof ServletDispatcherResult){ServletDispatcherResult result = (ServletDispatcherResult)realResult;logger.debug("jsp:\t"+result.getLastFinalLocation());}return resultCode;}}
以上是判断是否登陆和获取连接URL的拦截器。

本文出自 “小浩” 博客,请务必保留此出处http://zhangchi.blog.51cto.com/5214280/1309018

原创粉丝点击