📄 managersecurityinterceptor.java
字号:
package com.tech.webwork;
import org.apache.commons.lang.StringUtils;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.AroundInterceptor;
import com.tech.common.SystemConfig;
public class ManagerSecurityInterceptor extends AroundInterceptor {
/* (non-Javadoc)
* @see com.opensymphony.xwork.interceptor.AroundInterceptor#after(com.opensymphony.xwork.ActionInvocation, java.lang.String)
*/
@Override
protected void after(ActionInvocation arg0, String arg1) throws Exception {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.opensymphony.xwork.interceptor.AroundInterceptor#before(com.opensymphony.xwork.ActionInvocation)
*/
@Override
protected void before(ActionInvocation arg0) throws Exception {
// TODO Auto-generated method stub
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
before(invocation);
Object manager = ServletActionContext.getRequest().getSession().getAttribute(SystemConfig.ManagerSessionName);
if(manager==null){//未登录
return "nologinManager";
}else{
//判断用户有没有操作权限
String contextPath=ServletActionContext.getRequest().getContextPath();
String uri=ServletActionContext.getRequest().getRequestURI();
if(!StringUtils.isEmpty(contextPath)){
uri=StringUtils.substring(uri, StringUtils.indexOfDifference(uri, contextPath));
}
String result = invocation.invoke();
after(invocation, result);
return result;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -