📄 authorityinterceptor.java
字号:
package org.yeeku.authority;
import javax.servlet.http.HttpSession;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.yeeku.exception.AuctionException;
/**
* @author yeeku.H.lee kongyeeku@163.com
* @version 1.0
* <br>Copyright (C), 2005-2008, yeeku.H.Lee
* <br>This program is protected by copyright laws.
* <br>Program Name:
* <br>Date:
*/
public class AuthorityInterceptor implements MethodInterceptor
{
public Object invoke(MethodInvocation invocation) throws Throwable
{
HttpSession sess = null;
Object[] args = invocation.getArguments();
for (int i = 0 ; i < args.length ; i++ )
{
if (args[i] instanceof HttpSession) sess = (HttpSession)args[i];
}
Integer userId = (Integer)sess.getAttribute("userId");
if ( userId != null && userId.intValue() > 0)
{
return invocation.proceed();
}
else
{
throw new AuctionException("您还没有登陆,请先登陆系统再执行该操作");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -