</context-param>
<context-param>
<param-name>poststoragemode</param-name>
<param-value>1</param-value>
</context-param>
<listener>
<listener-class>com.laoer.bbscs.web.servlet.SysListener</listener-class>
</listener>
public class SysListener extends HttpServlet implements ServletContextListener { private static final Log logger = LogFactory.getLog(SysListener.class);
public void contextDestroyed(ServletContextEvent sce) {
//用于在容器关闭时,操作
}
//用于在容器开启时,操作
public void contextInitialized(ServletContextEvent sce) {
String rootpath = sce.getServletContext().getRealPath("/");
System.out.println("-------------rootPath:"+rootpath);
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);
其它略之....
}
}
/*最终输出
-------------rootPath:D:\tomcat_bbs\webapps\BBSCS_8_0_3\
2009-06-09 21:51:46,526 [com.laoer.bbscs.web.servlet.SysListener]-[INFO]
Application Run Path:D:/tomcat_bbs/webapps/BBSCS_8_0_3/
2009-06-09 21:51:46,526 [com.laoer.bbscs.web.servlet.SysListener]-[INFO]
web.xml中的参数context-param和init-param区别_IT/计算机_专业资料。web.xml...web.xml 中的参数 context-param 和 init-param 区别 2010-03-15 09:15:39...
监听器与context-prama标记的使用_IT/计算机_专业...ContextLoaderListener 的作用就是启动 Web 容器时,...<context-param> <param-name>contextConfigLocation...
init()与service()区别_计算机软件及应用_IT/计算机_专业资料。servlet中init(...context-param与init-pa... 13页 免费 web project和web servi... 5页 免费...
的init()方法中通过this.getInitParameter("param1"...ServletContext(); context-param的值 = ...但是他们并不同 <context-param>是application范围内...
(不同作用域数据的比 较),访问应用程序级初始化参数(context-param 与 init-param 比较),将消息记录到 应用程序日志文件中; Servlet 通信:向浏览器发送错误消息...
Detached状态和Transient状态的区别在于Detached状态的...()的作用是将数据库与缓存中的数据同步 11题:...<context-param> <param-name>contextConfigLocation...
-param> <param-name>contextConfigLocation</param-...视图 视图的作用是渲染模型数据,将模型里的数据以...为逻辑视图名的解析提供了不同的策略,可以在 Spring...
Servlet高级部分 说明我们今天讲的大部分是Servlet比较...init()方法 Init的作用? Init()方法 public void...servletContext 取得初始参数配置: <context-param> ...
两者的区别;画图演示,说明道理 Servlet实例 ? 实现...Init的作用? Init()方法 public void init(){ ?...context-param ServletContext对象 ? 与资源相关的...
热门文档