📄 adminsessioninterceptor.java
字号:
package com.laoer.bbscs.web.interceptor;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.commons.lang.*;
import net.sf.struts.saif.*;
import com.laoer.bbscs.comm.Constant;
import com.laoer.bbscs.web.action.ActionUtils;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.context.WebApplicationContext;
import com.laoer.bbscs.comm.AjaxMessagesXML;
import com.laoer.bbscs.comm.BBSCSUtil;
import com.laoer.bbscs.service.config.SysConfig;
/**
* <p>Title: Tianyi BBS</p>
*
* <p>Description: BBSCS</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: Laoer.com</p>
*
* @author Gong Tianyi
* @version 7.0
*/
public class AdminSessionInterceptor
implements ActionHaveForwardInterceptor {
public AdminSessionInterceptor() {
}
/**
* afterAction
*
* @param action Action
* @param actionMapping ActionMapping
* @param actionForm ActionForm
* @param httpServletRequest HttpServletRequest
* @param httpServletResponse HttpServletResponse
* @return ActionForward
* @throws IOException
* @throws ServletException
* @todo Implement this net.sf.struts.saif.ActionHaveForwardInterceptor method
*/
public ActionForward afterAction(Action action, ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws IOException,
ServletException {
return null;
}
/**
* beforeAction
*
* @param action Action
* @param actionMapping ActionMapping
* @param actionForm ActionForm
* @param httpServletRequest HttpServletRequest
* @param httpServletResponse HttpServletResponse
* @return ActionForward
* @throws IOException
* @throws ServletException
* @todo Implement this net.sf.struts.saif.ActionHaveForwardInterceptor method
*/
public ActionForward beforeAction(Action action, ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws IOException,
ServletException {
HttpSession session = httpServletRequest.getSession();
WebApplicationContext wc = WebApplicationContextUtils.getWebApplicationContext(action.
getServlet().getServletContext());
SysConfig sysConfig = (SysConfig) wc.getBean("sysConfig");
if (session.getAttribute(Constant.ADMIN_SESSION_KEY) == null) {
ActionMessages errors = new ActionMessages();
String ajax = httpServletRequest.getParameter("ajax");
if (StringUtils.isBlank(ajax)) {
ajax = "html";
}
if (ajax.equalsIgnoreCase("html")) {
errors.add("error.adminlogin.timeout", new ActionMessage("error.adminlogin.timeout"));
ActionUtils.addErrors(httpServletRequest, errors);
//return actionMapping.findForward("adminLogin");
return ActionUtils.getLoginForward(actionMapping, httpServletRequest, sysConfig, "admin");
}
else if (ajax.equalsIgnoreCase("shtml")) {
errors.add("error.adminlogin.timeout", new ActionMessage("error.adminlogin.timeout"));
ActionUtils.addErrors(httpServletRequest, errors);
//return actionMapping.findForward("adminLogin");
return ActionUtils.getLoginForward(actionMapping, httpServletRequest, sysConfig, "admin");
}
else {
AjaxMessagesXML ajaxMessagesXML = (AjaxMessagesXML) wc.getBean("ajaxMessagesXML");
ajaxMessagesXML.setMessage(Constant.CODEID_ADMIN_LOGIN_TIMEOUT,
Constant.MESSAGE.getMessage(httpServletRequest.getLocale(),
"error.adminlogin.timeout"));
httpServletRequest.setAttribute("xmlo", ajaxMessagesXML.getXmlo());
httpServletRequest.setAttribute("messagesDocument", ajaxMessagesXML.getMessagesDocument());
return actionMapping.findForward("ajaxjsp");
}
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -