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
872

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

  1. What is the difference between the two?

  2. What are the reasons or advantages for this choice?

仅有的幸福
仅有的幸福

reply all(2)
给我你的怀抱

The call of

Filterinit方法一定会在容器启动的时候执行,但Servletinit方法未必,要看load参数是怎么写的,默认的话,只有该Servlet首次被访问(访问路径匹配了urlMapping)才会触发init.

Also, compared to two init,我更喜欢把所有的初始化工作放在ServletContextListenercontextInitializedri.

某草草

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!