1
我试图用spring AOP编写拦截器。拦截器会发现请求URL是否为书签,如果是,将重定向到认证页面。 代码段:使用AOP-Spring拦截器的书签标记重定向
公共对象调用(的MethodInvocation调用)抛出的Throwable { logger.entering(this.getClass()getSimpleName(), “调用”,调用。);
Object result = null;
try {
// Logic to exclude the beans as per the list in the configuration.
boolean excluded = false;
for (String excludebean : excludedBeans) {
if (excludebean != null && excludebean.equalsIgnoreCase(invocation.getThis().getClass().getSimpleName())) {
excluded = true;
break;
}
}
// If the Target Method is "toString", then set EXCLUDE to TRUE and process the request
if(excluded == false && invocation.getMethod().getName().equalsIgnoreCase("toString"))
{
excluded = true;
}
// if user session object is available, then process the request or
// else forward to the configured view.
if (excluded || getSessionHolder().getUserVO() != null) {
result = invocation.proceed();
}
else {
logger.logp(Level.INFO, this.getClass().getSimpleName(),
"invoke(MethodInvocation)", "User Object is "+ getSessionHolder().getUserVO()
+ ". So redirecting user to home page");
result = new ModelAndView("redirect:/security/authenticate.do");
}
}
catch (Throwable ex) {
throw ex;
}
logger.exiting(this.getClass().getSimpleName(), "invoke");
return result;
}
当我调试控制而来的其他块内的预期,但之后我返回结果,控制转到用于书签网址ratehr比处理程序重定向视图handle方法。
请帮我对此..预先感谢。
谢谢丹尼,我会试试这个。 – RVP
我试过这种方式,我在拦截器内部有一个调试点,但控制器永远不会进入内部,我已将拦截器添加到中。我正在使用基于注解的url mapping.pls帮助。 –
RVP
请张贴您的代码和配置xml –