java - What is the difference between the init method of servlet and the init method of selecting Filter to load the configuration file?
仅有的幸福2017-05-17 10:07:44
0
2
900
springMVC chooses the init method of servlet to load the configuration file, while jfinal chooses the init method of Filter to load the configuration file
What is the difference between the two?
What are the reasons or advantages for this choice?
I also observed it some time ago, and I don’t quite understand that the execution order of filter and servlet is one before the other. I wonder if I chose to use servlet or filter due to design reasons
The call of
Filter
的init
方法一定会在容器启动的时候执行,但Servlet
的init
方法未必,要看load
参数是怎么写的,默认的话,只有该Servlet首次被访问(访问路径匹配了urlMapping
)才会触发init
.Also, compared to two
init
,我更喜欢把所有的初始化工作放在ServletContextListener
的contextInitialized
ri.I also observed it some time ago, and I don’t quite understand that the execution order of filter and servlet is one before the other. I wonder if I chose to use servlet or filter due to design reasons