syslistener.java

来自「一个jsp写的bbs」· Java 代码 · 共 57 行

JAVA
57
字号
package com.laoer.bbscs.web.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import com.laoer.bbscs.comm.*;

/**
 * <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 SysListener
    extends HttpServlet implements ServletContextListener {

  private static final Log logger = LogFactory.getLog(SysListener.class);

  //Notification that the web module is ready to process requests
  public void contextInitialized(ServletContextEvent sce) {
    String rootpath = sce.getServletContext().getRealPath("/");
    if (rootpath != null) {
      rootpath = rootpath.replaceAll("\\\\", "/");
    }
    else {
      rootpath = "/";
    }
    if (!rootpath.endsWith("/")) {
      rootpath = rootpath + "/";
    }
    Constant.ROOTPATH = rootpath;
    logger.info("Application Run Path:" + rootpath);
    String urlrewrtie = sce.getServletContext().getInitParameter("urlrewrite");
    boolean burlrewrtie = false;
    if (urlrewrtie != null) {
      burlrewrtie = Boolean.parseBoolean(urlrewrtie);
    }
    Constant.USE_URL_REWRITE = burlrewrtie;
    logger.info("Use Urlrewrite:" + burlrewrtie);
  }

  //Notification that the servlet context is about to be shut down
  public void contextDestroyed(ServletContextEvent sce) {
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?