src/web/yueqi/gita/interceptor/PrivilegeInterceptor.java
(完整代码) 1KBpackage web.yueqi.gita.interceptor;
import web.yueqi.gita.admin.entity.AdminUser;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
/**
* 权限拦截器:
*
*
*/
public class PrivilegeInterceptor extends MethodFilterInterceptor {
@Override
protected String doIntercept(ActionInvocation actionInvocation)
throws Exception {
// 判断是否登录,如果登录,放行,没有登录,跳转到登录页面.
AdminUser adminUser = (AdminUser) ServletActionContext.getRequest()
.getSession().getAttribute("existAdminUser");
if (adminUser != null) {
// 已经登录过
return actionInvocation.invoke();
} else {
// 跳转到登录页面:
ActionSupport support = (ActionSupport) actionInvocation
.getAction();
support.addActionError("您还没有登录!没有权限访问!");
return Action.LOGIN;
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。