獲取ServletContext的常用方法

2021-08-21 10:21:38 字數 656 閱讀 1998

伺服器會為每個應用建立乙個servletcontext物件:

servletcontext物件的作用是在整個web應用的動態資源之間共享資料!例如在aservlet中向servletcontext物件中儲存乙個值,然後在bservlet中就可以獲取這個值,這就是共享資料了。

1. 在servlet中獲取servletcontext物件:

在void init(servletconfig config)中:servletcontext context = config.getservletcontext();,servletconfig類的  getservletcontext()方法可以用來獲取servletcontext物件;

2. 在genericeservlet或httpservlet中獲取servletcontext物件:

genericservlet類有getservletcontext()方法,所以可以直接使用this.getservletcontext()來獲取;

獲取控制代碼獲取指標

1.獲取應用程式指標 2.獲取主框架指標 或者cmainframe pmainframe cmainframe afxgetmainwnd 3.獲取選單指標 cmenu pmenu afxgetmainwnd getmenu 4.獲取工具欄狀態列指標 1 主框架中可以直接使用m wnd m wnds...

獲取元素,獲取節點詳解

描述家庭族譜圖,只要我們獲得乙個元素,就可以通過很多的屬性或者方法找到頁面中的任何乙個元素 一 獲取元素的常用的8個方法 1 document.getelementbyid 1 id重複了,只獲取第乙個 2.ie6 7下不區分id大小寫 3.ie6 7下把表單元素name當作id使用 4.內嵌式引入...

tp5 1 獲取引數 獲取傳值 獲取url

方法都在 獲取引數方式一 class test 獲取引數方式二 構造方法注入 use think request class test 獲取引數方式三 構造方法注入 use think controller class test extends controller 獲取引數方式四 助手函式 use...