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();
}