梳理一下web總的一些概念

來源:互聯網
上載者:User

標籤:方法   java   str   jsp   get   conf   this   對象   使用   

servlet中的類適合繁複翻看文檔,熟悉各個類的常用方法,看一些經典的案例代碼。

ServletConfig

每個項目有多個servlet,每個servlet對應一個ServletCOnfigt對象。ServletConfig中封裝的是每個servlet的配置資訊,具體而言就是web.xml中<servlet></servlet>中的配置內容。

可以使用HttpSerlet的this.getSerletConfig方法獲得servletconfig

 

 

ServletContext:

每個項目對應一個ServletContext,ServletContext實體封裝的內容對應web.xml中的配置資訊,這包含的內容就比較的多了。在一個servlet中可以使用thi.getServletConfig().getServletContext()擷取ServletContext也可以使用直接使用this.getServletContext()直接擷取,後者中也是調用的第一個的方法。

 

從上面就就可以看出來,ServletContext的範圍比ServletConfig的範圍更大一些。

servlet中的域對象

  ServletContext,HttpServletRequest,HttpSession。

jsp中的域對象(當然都是jsp9大內建對象)

  applicaltion,HttpServletRequest,HttpSession,PageContext。application其實就是ServletContext(可以直接查看jsp翻譯成的java檔案)

 

梳理一下web總的一些概念

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.