我認爲你的問題是在登錄頁面上的用戶未登錄時重定向用戶。在每個actionBean上使用@before不是一個好主意。爲了達到這個目的,你可以通過擴展SpringInterceptorSupport來製作你自己的攔截器。
@Intercepts(LifecycleStage.ActionBeanResolution)
public class MyInterceptor extends SpringInterceptorSupport {
private static final List<Class<? extends ActionBean>> ALLOW = Arrays.asList(LoginActionBean.class, anyOtherActionBeanAllowedWithoutLogin.class);
@Override
@SuppressWarnings({ "rawtypes" })
public Resolution intercept(ExecutionContext execContext) throws Exception {
Resolution resolution = execContext.proceed();
ActionBean actionBean = execContext.getActionBean();
Class<? extends ActionBean> destinationclass = actionBean.getClass();
if (!ALLOW.contains(destinationclass) && !isSessionExist()) {
resolution = new RedirectResolution(LoginActionBean.class);
}
return resolution;
}
private boolean isSessionExist() {
String login = (String)context.getRequest().getSession().getAttribute("login");
return login != null;
}
}
你當然也可以編寫自己的攔截器:http://www.stripesframework.org/display/stripes/Intercept+Execution(這很容易!) – Kdeveloper 2011-01-10 22:52:04