spring boot20深度实践之核心技术篇课纲第七节渐行渐远的servlet_第1页
spring boot20深度实践之核心技术篇课纲第七节渐行渐远的servlet_第2页
spring boot20深度实践之核心技术篇课纲第七节渐行渐远的servlet_第3页
spring boot20深度实践之核心技术篇课纲第七节渐行渐远的servlet_第4页
spring boot20深度实践之核心技术篇课纲第七节渐行渐远的servlet_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

渐行渐远的 ServletServlet是一种基JavaWeb组件,用于生成动态内容,由容器管理。类似于其他Java技术组件,Servlet是平台无Java类组成,并且JavaWeb服务器加载执行。通常情况Servlet容器提供运行时环境。Servlet容器,有时候也称作为Servlet引擎,作为Web服务器或应用服务器的一部分。通过请求和响应,提供Web客户端与Servlets交互的能从功能上,Servlet介于CGI(CommonGatewayInterface)与服务扩展(如:NetscapeServerAPI或Apache模块)之在体系上,Servlet技术(或者规范)属于JavaEE技术(规范)的一部分。不过Servlet并非一开始就隶属于J2EEJavaEE。接下来的小节将会介绍ServletServlet版Java平Servlet20179JavaEEServlet20135JavaEE非阻塞I/O、HTTP协议更新机制Servlet200912JavaEEServlet20059JavaEEAnnotationServlet200311J2EEweb.xml支持XMLServlet20018J2EE新增Filter Servlet19998J2EEJ2EE的一部分,以.war文件作为独立web应Servlet组件SpringFrameworkServletServlet无ServletContext生命周期ServletRequest生命周期ReqHttpSession生命周期异步上下文ServletServlet方传统方注解方编程方Servletweb.xml部署<servlet>+<servlet-mapFilterweb.xml部署<filter>+<filter-map*Listenerweb.xml部署<?xml<?xmlversion="1.0"encoding="UTF-<web-appplete="true""/xml/ns/javaee<context-Spring配置文件路该参数值将被org.springframework.web.context.ContextLoaderListener使<param-name>contextConfigLocation</param-<param-classpath*:/META-INF/spring/spring-</param-</context-org.springframework.web.context.ContextLoaderListener为可选申明<listener-class>org.springframework.web.context.ContextLoaderListener</listener-</web-SpringServlet理 生命周初始化:服务:销毁:理

理 生命周初始化:销毁:Servlet异步 SpringBootServletSpringBoot嵌入式Servlet容器限Servlet兼容解决方不支RegistrationBean或@Bean不支@WebServlet有限支依 87.2ConvertanExistingApplicationtoSpringBootyoumayneedtoaddsomeconfigurationto,as

context,byrecingthoseelementsfromA@BeanoftypeServlet

installsthatbeaninthecontainerasifitwere

and<servlet-map/>inweb.xmlA@BeanoftypeFilterorFilterRegistrationBeanbehavessimilarly(asmap/>AnApplicationContextinanXMLfilecanbeaddedthrough

in Alternatively,simplecaseswhereannotationconfigurationisheavilyusedalreadycanberecreatedinafewlinesas 27.4.2ServletContextEmbeddedservletcontainersdonotdirectlyexecutetheServletinterface.ThisisanintentionaldesigndecisionintendedtoreducetheriskthatthirdpartylibrariesdesignedtoruninsideawarmaybreakSpringBootScanningforServlets,Filters,andWhenusinganembeddedcontainer,automaticregistrationofclasses , canbeenabledby SpringBootServlet通 扫描package- 通 通 SpringBoot应用传统Servlet使用Tomcat7插件(Servlet<artifactId>tomcat7-maven-<id>tomcat-<goal>exec-war-<!--ServletContextpath--使用Tomcat8插件(Servlet<!--Tomcat8Maven插件用于构建可执行war<!-- /artifact/org.apache.tomcat.maven/tomcat8-maven-plugin--<artifactId>tomcat8-maven-<version>3.0- <id>tomcat-最终打包成可执行的jar包<goal>exec-war-ServletContext路径tomcat8-maven-plugin所在仓库<name>Alfresco /nexus/content/repositories/p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论