背景:读Spring团购项目源码时,CtxInterceptor在postHandle()里会调用request.getContextPath()得到项目名并将其拼接后设置到model里。在intellij里跟踪代码发现HttpServletRequest为接口,其实现类HttpServletRequestWrapper只是包装类,需要先传入实例化的HttpServletRequest进行初始化。猜测HttpServletRequest是由tomcat之类的web容器实例化的,在google中搜到如下链接,得出HttpServletRequest是由servlet container实例化的。servlet container与web server的关系有三种,work closely with,embedded,include。tomcat就是include web server的servlet container
参考链接:
https://coderanch.com/t/347181/java/class-implements-HttpServletRequest-interface-javax