获取 ServletContext 对象 | 学习笔记

简介: 快速学习获取 ServletContext 对象。

开发者学堂课程【Servlet 入门:获取 ServletContext 对象】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址:https://developer.aliyun.com/learning/course/34/detail/752


获取 ServletContext 对象


内容介绍

一、获取 ServletContext 对象


一、获取 ServletContext 对象

ServetConfigtgetserxletContext);

GenericServlet#getServletContext();

HtesessiongetSarxletContext()

ServletcontextEventgetServletContext)

Servlet ServletContext 对象;
void init(ServletConfig config) :
ServletContext context = config getServletContext();ServetConfig.类的getServetContext!(方法可以用来获取 ServletContext 对象; GenericeServlet HttpServlet中获取 ServletContext 对象: .
GenericServlet.
类有 getServletContext0 方法,所以可以直接使用this.getservletContext() 来获取;
 

public class MyServlet implements Servlet {
public void init(ServletConfig config) {
ServletContext context = config.setServletContext();
public class MyServlet extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response) {

ServletContext context = this.getSevletContext();

相关文章
|
6月前
|
存储 对象存储
07JavaWeb基础 - ServletContext对象
07JavaWeb基础 - ServletContext对象
20 0
|
10月前
|
存储 应用服务中间件 测试技术
Servlet中的ServletConfig对象、ServletContext对象以及Servlet3.0
Servlet中的ServletConfig对象、ServletContext对象以及Servlet3.0
53 1
|
11月前
|
应用服务中间件 容器
ServletConfig、ServletContext概述、配置及ServletContext的三个作用
ServletConfig、ServletContext概述、配置及ServletContext的三个作用
117 0
Servlet学习(六):ServletContext对象的作用
Servlet学习(六):ServletContext对象的作用
Servlet学习(六):ServletContext对象的作用
Servlet——ServletContext对象功能
Servlet——ServletContext对象功能
73 0
|
XML Java 应用服务中间件
谈谈 ServletConfig 和 ServletContext
我们都知道Servlet是框架的灵魂,学习web框架最底层离不开Servlet的支持,那么Servlet 是什么呢?如何创建一个Servlet 不是本文的重点,相关文章可以参考
75 0
|
缓存 容器
ServletContext对象的使用
如何使用ServletContext对象
ServletContext对象
ServletContext对象原理介绍
ServletContext对象

热门文章

最新文章