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?
The call of
Filter
的init
方法一定會(huì)在容器啟動(dòng)的時(shí)候執(zhí)行,但Servlet
的init
方法未必,要看load
參數(shù)是怎么寫的,默認(rèn)的話,只有該Servlet首次被訪問(訪問路徑匹配了urlMapping
)才會(huì)觸發(fā)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