managersecurityinterceptor.java
来自「使用WEBWORK,SPRING,HIBERNATE编写的简单的添加」· Java 代码 · 共 47 行
JAVA
47 行
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 + =
减小字号Ctrl + -
显示快捷键?