当前位置:网站首页>GenericServlet为什么有两个init方法
GenericServlet为什么有两个init方法
2022-07-27 03:39:00 【散散汪】
init(ServletConfig config)负责初始化config对象,次方法调用了init() 后者没有任何实现,后者的作用是让开发者在继承此类的时候重写init()方法,不要继承init(ServletConfig config),从而避免了因为没有调用super.init(config)而没有对config初始化。
只要我们复写无参的init方法,tomcat在调用完有参的init方法时调用无参的init方法,这样两个操作都执行了。而且我们也不用写super.init();试想一下,如果没有无参的init方法,那我们复写有参的init方法时忘记了些super.init(config)方法,那么config就不能初始化了,而这样设计即使我们不调用super的方法,也不会出问题。何乐而不为呢!
反正就是套娃
边栏推荐
- 整理字符串
- MySQL: understand the basic knowledge of MySQL and computer
- 法解析的外部符号 “public: virtual __cdecl nvinfer1::YoloLayerPlugin::~YoloLayerPlugin(void)“ “public: virtua
- Leetcode daily exercise: sort sentences
- 网工知识角|只需四个步骤,教会你使用SecureCRT连接到eNSP,常用工具操作指南必看
- scala 不可变Map 、 可变Map 、Map转换为其他数据类型
- 卷积神经网络——24位彩色图像的卷积的详细介绍
- VR panorama gold rush "careful machine" (Part 1)
- Maximum nesting depth of parentheses
- 面试题 02.05. 链表求和
猜你喜欢

Practice of microservice in solving Library Download business problems

Session&Cookie&token

Is VR panoramic production a single weapon in the home decoration industry? Why is this?

Navicat exports Mysql to table structure and field description

2022 operation of simulated examination question bank and simulated examination platform for safety production management personnel of hazardous chemical production units

微信小程序轮播图

Principle of bean validation --07

list模拟实现

js三种遍历数组的方法:map、forEach、filter

ArrayList与LinkedList区别
随机推荐
人很话不多,工程师不耍嘴皮子
Detailed explanation of TCP protocol knowledge
【软件工程期末复习】知识点+大题详解(E-R图、数据流图、N-S盒图、状态图、活动图、用例图....)
佳明手表怎么设置用户定制显示
Ribbon负载均衡策略与配置、Ribbon的懒加载和饥饿加载
[small sample segmentation] msanet: multi similarity and attention guidance for boosting few shot segmentation
一张图看懂KingbaseES V9
微服务化解决文库下载业务问题实践
【无标题】
搜索旋转排序数组
BigDecimal pit summary & Best Practices
How CentOS installs mysqldump
Brightcove appoints Dan Freund as chief revenue Officer
Introduction to JVM principle
Word/Excel 固定表格大小,填写内容时,表格不随单元格内容变化
电商分账系统重要吗,平台应该如何选择分账服务商呢?
每日一题:奇偶树
Is VR panoramic production a single weapon in the home decoration industry? Why is this?
What is the principle difference between lateinit and lazy in kotlin
Learning route from junior programmer to architect + complete version of supporting learning resources