zoukankan      html  css  js  c++  java
  • APPFUSE拦截器的添加!。

    404.jsp中加入<c:redirect url="/login.jsp"/>
    把web.xml中加入
    <error-page>
      <error-code>404</error-code>
      <location>/404.jsp</location>
     </error-page>s
    struts.xml
    <action name="main" class="mainAction" method="main">
    <interceptor-ref name="currentCheck" />
    <result name="success">/WEB-INF/pages/main.jsp</result>
    <result name="shibai">/logout.jsp</result>
    </action>
    org.aninggo.webapp.interceptor.AuthzInterceptor
    public String intercept(ActionInvocation invocation) throws Exception {
    if (invocation.getAction() instanceof AuthzAware){
    Authz authz
    = new AuthzImpl();
    AuthzAware authzAware
    = (AuthzAware) invocation.getAction();
    authzAware.setAuthz(authz);
    }

    SecurityContext ctx
    = SecurityContextHolder.getContext();
    Authentication auth
    = ctx.getAuthentication();
    if (auth.getPrincipal() != null){
    try{
    UserDetails user
    = (UserDetails) auth.getPrincipal();

    if (user.getUsername() == null){
    System.out.println(
    "空的");
    return "shibai";
    }
    System.out.println(user.getUsername());
    }
    catch (Exception e){
    // TODO: handle exception
    return "shibai";
    }

    }
    return invocation.invoke();
    }
  • 相关阅读:
    HDU1266 Reverse Number
    codevs1380 没有上司的舞会
    codevs1163 访问艺术馆
    codevs2144 砝码称重 2
    codevs1553 互斥的数
    codevs1230 元素查找
    codevs3118 高精度练习之除法
    codevs1245 最小的N个和
    codevs1063 合并果子
    codevs1052 地鼠游戏
  • 原文地址:https://www.cnblogs.com/zyxzhsh/p/2027308.html
Copyright © 2011-2022 走看看