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?
给我你的怀抱2017-05-17 10:09:44
The call of
Filter
的init
方法一定会在容器启动的时候执行,但Servlet
的init
方法未必,要看load
参数是怎么写的,默认的话,只有该Servlet首次被访问(访问路径匹配了urlMapping
)才会触发init
.
Also, compared to two init
,我更喜欢把所有的初始化工作放在ServletContextListener
的contextInitialized
ri.
某草草2017-05-17 10:09:44
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