Blage's Coding Blage's Coding
Home
算法
  • 手写Spring
  • SSM
  • SpringBoot
  • JavaWeb
  • JAVA基础
  • 容器
  • Netty

    • IO模型
    • Netty初级
    • Netty原理
  • JVM
  • JUC
  • Redis基础
  • 源码分析
  • 实战应用
  • 单机缓存
  • MySQL

    • 基础部分
    • 实战与处理方案
    • 面试
  • ORM框架

    • Mybatis
    • Mybatis_Plus
  • SpringCloudAlibaba
  • MQ消息队列
  • Nginx
  • Elasticsearch
  • Gateway
  • Xxl-job
  • Feign
  • Eureka
  • 面试
  • 工具
  • 项目
  • 关于
🌏本站
🧸GitHub (opens new window)
Home
算法
  • 手写Spring
  • SSM
  • SpringBoot
  • JavaWeb
  • JAVA基础
  • 容器
  • Netty

    • IO模型
    • Netty初级
    • Netty原理
  • JVM
  • JUC
  • Redis基础
  • 源码分析
  • 实战应用
  • 单机缓存
  • MySQL

    • 基础部分
    • 实战与处理方案
    • 面试
  • ORM框架

    • Mybatis
    • Mybatis_Plus
  • SpringCloudAlibaba
  • MQ消息队列
  • Nginx
  • Elasticsearch
  • Gateway
  • Xxl-job
  • Feign
  • Eureka
  • 面试
  • 工具
  • 项目
  • 关于
🌏本站
🧸GitHub (opens new window)
  • 手写Spring

  • SSM

  • SpringBoot

  • JavaWeb

    • 前端基础
    • 后端基础
    • Thymeleaf视图模板
    • session会话
    • Servlet
    • Servlet优化
    • 依赖注入
    • 过滤器
    • 监听器
    • 正则表达式
    • 项目经验
  • Spring
  • JavaWeb
phan
2023-05-15

监听器

# 监听器

ServletContextListener——监听ServletContext对象的创建销毁的过程

HttpSessionListener——监听HttpSession

ServletRequestListener——监听ServletRequest


ServletContextAttributeListener——监听ServletContext的保存作用域的改动

HttpSessionAttributeListener——监听HttpSession属性

ServletRequestAttributeListener——监听ServletRequest属性

序列化:冻化,把内存中的对象冷冻到磁盘中。

反序列化:活化,把磁盘中的对象激活加载到内存。

应用场景:当上下文切换时再创建bean工厂,将其保存到application作用域,然后中央控制器初始化再从上下文作用域getServletContext获取对象。

@WebListener
public class ContextLoaderListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext();
        ServletContext application = servletContextEvent.getServletContext();
        application.setAttribute("beanFactory", beanFactory);
}}
1
2
3
4
5
6
7
8
编辑 (opens new window)
#JavaWeb
上次更新: 2023/12/15, 15:49:57
过滤器
正则表达式

← 过滤器 正则表达式→

Theme by Vdoing | Copyright © 2023-2024 blageCoder
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式