35

关于 Java 类加载器的这一点,市面上没有任何一本图书讲到-wx5cb6d3d725767的博客

 4 years ago
source link: https://blog.51cto.com/14295088/2413630
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
大家都知道,Tomcat 处理业务,靠什么?最终是靠我们自己编写的 Servlet。你可能说你不写 servlet,你用 spring MVC,那也是人家帮你写好了,你只需要配置就行。在这里,有一个边界,Tomcat 算容器,容器的相关 jar 包都放在它自己的 安装目录的 lib 下面; 我们呢,算是业务,算是webapp,我们的 servlet ,不管是自定义的,还是 spring mvc 的DispatcherServlet,都是放在我们的 war 包里面 WEB-INF/lib下。 看过前面文章的同学是晓得的, 这二者是由不同的类加载器加载的。在 Tomcat 的实现中,会委托 webappclassloader 去加载WAR 包中的 servlet ,然后 反射生成对应的 servlet。后续有请求来了,调用生成的 servlet 的 service 方法即可。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK