传统Web应用项目:
最常用的三大组件有Servlet、Filter和Listener。使用这些组件时需要在项目的web.xml文件中进行配置,或者使用相应的注解进行标注。
Spring Boot项目:
默认没有web.xml文件,同时默认情况下Spring Boot项目不能自动识别到这三个组件的相关注解。可以使用Spring Bean、RegistrationBean、注解扫描的方式注册Java Web三大组件。
1.servlet和controller
联系:定位接收请求、处理请求、响应请求
区别:servlet 是java web基础组件,功能简单,操作麻烦;controller是spring mvc组件,功能强大,操作简单
2.filter和interceptor
联系:定位过滤/拦截请求
区别:filter是java web的基础组件,功能简单,操作灵活,类似于毛坯房;interceptor是spring mvc组件,功能强大,操作简单,类似于精装房
3.listener
java web listener:监听web相关作用域,request、session、servletContext 创建关闭
Spring listener:监听Spring容器 ,容器启动、关闭、停止、刷新
8905

被折叠的 条评论
为什么被折叠?



