首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

struts2 interceptor 获取访问种及方法进行拦截

2012-06-30 
struts2 interceptor 获取访问类及方法进行拦截public class LoginInterceptor extends AbstractIntercept

struts2 interceptor 获取访问类及方法进行拦截

public class LoginInterceptor extends AbstractInterceptor {

?? @Override
?? public String intercept(ActionInvocation invocation) throws Exception {
?????? ? ActionProxy proxy = invocation.getProxy();
???????? String methodName = proxy.getMethod();
???????? String actionName = proxy.getActionName();
???????? if ("login".equals(actionName)) {
????????????? ?return invocation.invoke();
???????? }
???????? if (!(isLogin())) {
??????????? ActionContext actionContext = invocation.getInvocationContext();
??????????? HttpServletRequest request = (HttpServletRequest) actionContext
?????????????????????????????? .get(StrutsStatics.HTTP_REQUEST);
??????????? HttpServletResponse response = (HttpServletResponse) actionContext
?????????????????????????????? .get(StrutsStatics.HTTP_RESPONSE);
?????????? response.sendRedirect(request.getContextPath()
??????????????????????? + "/loginmgmt/login!login.action");?
???????????return null;
???????? }
??????? return invocation.invoke();
??? }

}

?

热点排行