文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > context-param与init-param的区别与作用
侵权投诉

context-param与init-param的区别与作用

</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]

上一页第2页

你可能喜欢

热门文档

相关文档

  • web.xml中的参数context-param和init-param区别

    web.xml中的参数context-param和init-param区别_IT/计算机_专业资料。web.xml...web.xml 中的参数 context-param 和 init-param 区别 2010-03-15 09:15:39...

  • ContextLoaderListener监听器与context-prama标记的使用

    监听器与context-prama标记的使用_IT/计算机_专业...ContextLoaderListener 的作用就是启动 Web 容器时,...<context-param> <param-name>contextConfigLocation...

  • init()与service()区别

    init()与service()区别_计算机软件及应用_IT/计算机_专业资料。servlet中init(...context-param与init-pa... 13页 免费 web project和web servi... 5页 免费...

  • web.xml的解析

    的init()方法中通过this.getInitParameter("param1"...ServletContext(); context-param的值 = ...但是他们并不同 <context-param>是application范围内...

  • 企业级java1

    (不同作用域数据的比 较),访问应用程序级初始化参数(context-param 与 init-param 比较),将消息记录到 应用程序日志文件中; Servlet 通信:向浏览器发送错误消息...

  • 答案

    Detached状态和Transient状态的区别在于Detached状态的...()的作用是将数据库与缓存中的数据同步 11题:...<context-param> <param-name>contextConfigLocation...

  • Spring-MVC_v2

    -param> <param-name>contextConfigLocation</param-...视图 视图的作用是渲染模型数据,将模型里的数据以...为逻辑视图名的解析提供了不同的策略,可以在 Spring...

  • Servlet高级篇_IT/计算机_专业资料

    Servlet高级部分 说明我们今天讲的大部分是Servlet比较...init()方法 Init的作用? Init()方法 public void...servletContext 取得初始参数配置: <context-param> ...

  • Servlet

    两者的区别;画图演示,说明道理 Servlet实例 ? 实现...Init的作用? Init()方法 public void init(){ ?...context-param ServletContext对象 ? 与资源相关的...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email