拦截器手动实现,要实现相应的拦截器接口
登陆验证的拦截器:
@Component
public class CheckLoginInterceptor implements Interceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
// TODO Auto-generated method stub
Action action = (Action) invocation.getAction();
if (action instanceof LoginAction) {
String method = invocation.getProxy().getMethod();
if (method.equals("logout")) {
HttpServletRequest request = (HttpServletRequest) invocation
.getInvocationContext().get(
ServletActionContext.HTTP_REQUEST);
HttpSession session = request.getSession();
invocation.getInvocationContext().getSession();
session.invalidate();// 清除缓存
return "toLogin";
} else {
return invocation.invoke();
}
}else {
BackUserModel pm = (BackUserModel) invocation.getInvocationCo