request
Servlet 是一组关于请求的 API 与 interfaces. springmvc(spring 处理 web 层请求的模块) 是对于 Servlet 的实现.
Tomcat服务器 = Web服务器(静态资源) + Servlet/JSP容器(Web容器:动态资源转换为静态资源)SpringBoot 在启动过程中,也包括了 Tomcat 的启动(ref)
关于 JavaContainer: a kind of component that holds and manages other components.
- Your code does not have any main() or "wait here for a request logic" - the container starts up and configures itself and then eventually initialises your code and delivers requests
- Your code may be one of many similar classes (servlets in a servlet container, EJBs in an EJB container) whose instances have life-cycles to be controlled by the container.
- Requests are delivered to your servlet or EJB via some protocol defined by the container, using resources (eg. HTTP ports) controlled by the container, and possibly with considerable infrastructure cleverness (look at the HTTP request queues, EJB load balancing etc.)
- There's considerable added value from functions such as transaction control and security management - as the container is calling your code it is well-placed to implement this unintrusively.
- The main container functionality is very much IOC, the container calls your code at appropriate times, however the container will also provide useful APIs that your code can call (eg. to get Servlet or EJB Contexts.
(---> 豆知识:Tomcat 的命令行名字叫 Catalina 它实际上是加州的 Santa Catalina Island 圣卡塔利娜岛。作者说他写代码的时候猫咪总是围着显示器转 再加上他一直很想去那个岛屿旅游haha)
SecurityHolder
提供当前使用人的安全上下文
保存设置
默认 ThreadLocal(一个请求线程), 如果涉及到微服务和服务转发的,用 MODE_INHERITABLETHREADLOCAL(子线程也可)