`

getServletContext()和getServletConfig()的意思!

阅读更多
getServletConfig()  
   
   在servlet初始化时,容器传递进来一个ServletConfig对象并保存在servlet实例中,该对象允许访问两项内容:初始化参数和ServletContext对象,前者通常由容器在文件中指定,允许在运行时向sevrlet传递有关调度信息,比如说getServletConfig().getInitParameter("debug")后者为servlet提供有关容器的信息。此方法可以让servlet在任何时候获得该对象及配置信息。  

getServletContext()  

   一个servlet可以使用getServletContext()方法得到web应用的servletContext  
   即而使用getServletContext的一些方法来获得一些值  
   比如说getServletContext().getRealPath("/")来获得系统绝对路径  
  getServletContext().getResource("WEB-INF/config.xml")来获得xml文件的内容
分享到:
评论

相关推荐

    spring+hibernate+osworkflow

    ApplicationContext cxt = WebApplicationContextUtils.getWebApplicationContext(this.getServletConfig().getServletContext()); Workflow wf = (Workflow)cxt.getBean("workflow"); 用osworkflow自带的designer把...

    ServLetContext基础

    ServLetContext 解决的问题:不同的用户使用相同的数据 就是不同的用户,访问...ServletContext sc1=this.getServletConfig().getServletContext(); ServletContext sc2=req.getSession().getServletContext(); 注意

    java网站开发结合jsp写的上传以及批量上传文件代码

    su.initialize(getServletConfig(), request, response); // 5:上传 su.upload(); // 拿取Smartupload的request // 注意当我们使用了SmartUpload此jar包后 // 无法再次使用httpServletRequest这...

    基于JAVa的网上商城项目完整源码.zip

    out.print(this.getClass() + this.getServletConfig().getServletContext().getInitParameter("a")); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); out....

    千方百计笔试题大全

    185、getServletContext()和getServletConfig()的意思 44 186、Hashtable和HashMap 44 187、JAVA SERVLET API中forward() 与redirect()的区别? 44 189、Can a Java Thread be started from Servlet class, and what...

    java面试宝典

    185、getServletContext()和getServletConfig()的意思 44 186、Hashtable和HashMap 44 187、JAVA SERVLET API中forward() 与redirect()的区别? 44 189、Can a Java Thread be started from Servlet class, and what...

    网上书城 购物系统 jsp

    out.print(this.getClass() + this.getServletConfig().getServletContext().getInitParameter("a")); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); out....

    网上购物系统

    out.print(this.getClass() + this.getServletConfig().getServletContext().getInitParameter("a")); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); ...

    JSP 获取Spring 注入对象示例

    <%@ page import=org.springframework.web.context...ServletContext sc = this.getServletConfig().getServletContext(); ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(sc);

    jsp内置对象的用法

    7 ServletConfig getServletConfig() 返回当前页的ServletConfig对象(config) 8 ServletContext getServletContext() 返回当前页的ServletContext对象(application) 9 void setAttribute(String name,Object ...

    +Flex+集成到+Java+EE+应用程序的最佳实践(完整源代码)

    FlexContext.getServletConfig().getServletContext() ); String beanName = getSource(); try { log.info("Lookup bean from Spring ApplicationContext: " + beanName); return appContext.getBean(bean...

    将 Flex 集成到 Java EE 应用程序的最佳实践(完整源代码)

    FlexContext.getServletConfig().getServletContext() ); String beanName = getSource(); try { log.info("Lookup bean from Spring ApplicationContext: " + beanName); return appContext.getBean...

    servlet2.4doc

    Overview Package Class Tree Deprecated Index Help PREV NEXT FRAMES NO FRAMES A B C D E F G H I J L P R S U V -------------------------------------------------------------------------------- ...

Global site tag (gtag.js) - Google Analytics