struts1.2+spring2.0+hibernate
我用aop来验证权限,完了之后要怎么跳到一个页面 呢?
package net.ch.aop;
import org.aspectj.lang.JoinPoint;/**
@author Administrator
*
/
public class SecurityBiz{
/**
@throws Exception
*/
public void before(JoinPoint point) throws Exception
{
System.err.println("您正在执行:"+point.getTarget().getClass().getName()+" 的:"+point.getSignature().getName()+"方法!");
System.out.println("验证权限中....");
System.out.println("pass");
//throw new net.ch.aop.exception.SecurityException("e");
}
}
我试过用struts配置文件来捕捉异常跳转但是也不行,请大家帮_帮_忙,急啊,先谢过了。
问题补充:
首先感谢的zxowl的回答,但是我就是不想到过滤器里验证啊,通过AOP我就可以指定哪些类和方法。
我试过用ThreadLocal 加filter但是好象出了点问题,明天我抱空异常,赶明儿我再试试。
验证权限 你应该放到过滤中去做
/**
....处理....
//返回信息页
req.getRequestDispatcher("/index.jsp").forward(request, response);
}
aop应用:
public class ExceptionAdvice implements ThrowsAdvice {
Logger logerror=Logger.getLogger("logError");// 错误日志
public void afterThrowing(Method method, Object[] args, Object target,
Throwable subclass) throws ParseException {
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
logerror.error("---begin-----------------------------------------------------------");
logerror.error("[异常日志]\n 时间:" + sim.format(new Date())
+ " 业务类:" + target.getClass().getName() + "\n业务方法:"
+ method.getName() + "\n 参数:" + printArray(args)
+ "\n 异常信息:" + subclass.getMessage() + "\n 堆栈信息:"
+ subclass.getStackTrace());
logerror.info("---end-------------------------------------------------------------");
logerror.error("");
}