springboot 不响应字段为空_面试官扎心一问:Tomcat 在 SpringBoot 中是如何启动的?...

作者:木木匠

http://my.oschina.net/luozhou/blog/3088908

前言

我们知道 SpringBoot 给我们带来了一个全新的开发体验,我们可以直接把 web 程序达成 jar 包,直接启动,这就得益于 SpringBoot 内置了容器,可以直接启动,本文将以 Tomcat 为例,来看看 SpringBoot 是如何启动 Tomcat 的,同时也将展开学习下 Tomcat 的源码,了解 Tomcat 的设计。

从 Main 方法说起

用过 SpringBoot 的人都知道,首先要写一个 main 方法来启动

@SpringBootApplication
public class TomcatdebugApplication {public static void main(String[] args) {SpringApplication.run(TomcatdebugApplication.class, args);}}

我们直接点击 run 方法的源码,跟踪下来,发下最终的 run 方法是调用 ConfigurableApplicationContext 方法,源码如下:

public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;Collection<springbootexceptionreporter> exceptionReporters = new ArrayList&lt;&gt;();//设置系统属性『java.awt.headless』,为true则启用headless模式支持configureHeadlessProperty();//通过*SpringFactoriesLoader*检索*META-INF/spring.factories*,//找到声明的所有SpringApplicationRunListener的实现类并将其实例化,//之后逐个调用其started()方法,广播SpringBoot要开始执行了SpringApplicationRunListeners listeners = getRunListeners(args);//发布应用开始启动事件listeners.starting();try {//初始化参数ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);//创建并配置当前SpringBoot应用将要使用的Environment(包括配置要使用的PropertySource以及Profile),//并遍历调用所有的SpringApplicationRunListener的environmentPrepared()方法,广播Environment准备完毕。ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);//打印bannerBanner printedBanner = printBanner(environment);//创建应用上下文context = createApplicationContext();//通过*SpringFactoriesLoader*检索*META-INF/spring.factories*,获取并实例化异常分析器exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);//为ApplicationContext加载environment,之后逐个执行ApplicationContextInitializer的initialize()方法来进一步封装ApplicationContext,//并调用所有的SpringApplicationRunListener的contextPrepared()方法,【EventPublishingRunListener只提供了一个空的contextPrepared()方法】,//之后初始化IoC容器,并调用SpringApplicationRunListener的contextLoaded()方法,广播ApplicationContext的IoC加载完成,//这里就包括通过**@EnableAutoConfiguration**导入的各种自动配置类。prepareContext(context, environment, listeners, applicationArguments, printedBanner);//刷新上下文refreshContext(context);//再一次刷新上下文,其实是空方法,可能是为了后续扩展。afterRefresh(context, applicationArguments);stopWatch.stop();if (this.logStartupInfo) {new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);}//发布应用已经启动的事件listeners.started(context);//遍历所有注册的ApplicationRunner和CommandLineRunner,并执行其run()方法。//我们可以实现自己的ApplicationRunner或者CommandLineRunner,来对SpringBoot的启动过程进行扩展。callRunners(context, applicationArguments);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, listeners);throw new IllegalStateException(ex);}try {//应用已经启动完成的监听事件listeners.running(context);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, null);throw new IllegalStateException(ex);}return context;}

其实这个方法我们可以简单的总结下步骤为 > 1. 配置属性 > 2. 获取监听器,发布应用开始启动事件 > 3. 初始化输入参数 > 4. 配置环境,输出 banner > 5. 创建上下文 > 6. 预处理上下文 > 7. 刷新上下文 > 8. 再刷新上下文 > 9. 发布应用已经启动事件 > 10. 发布应用启动完成事件

其实上面这段代码,如果只要分析 tomcat 内容的话,只需要关注两个内容即可,上下文是如何创建的,上下文是如何刷新的,分别对应的方法就是 createApplicationContext() 和 refreshContext(context),接下来我们来看看这两个方法做了什么。

protected ConfigurableApplicationContext createApplicationContext() {Class<!--?--> contextClass = this.applicationContextClass;if (contextClass == null) {try {switch (this.webApplicationType) {case SERVLET:contextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS);break;case REACTIVE:contextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS);break;default:contextClass = Class.forName(DEFAULT_CONTEXT_CLASS);}}catch (ClassNotFoundException ex) {throw new IllegalStateException("Unable create a default ApplicationContext, " + "please specify an ApplicationContextClass",ex);}}return (ConfigurableApplicationContext) BeanUtils.instantiateClass(contextClass);}

这里就是根据我们的 webApplicationType 来判断创建哪种类型的 Servlet,代码中分别对应着 Web 类型(SERVLET),响应式 Web 类型(REACTIVE),非 Web 类型(default),我们建立的是 Web 类型,所以肯定实例化 DEFAULT_SERVLET_WEB_CONTEXT_CLASS 指定的类,也就是 AnnotationConfigServletWebServerApplicationContext 类,我们来用图来说明下这个类的关系

b2c7f90033672afb2ee81d1141a89160.png

通过这个类图我们可以知道,这个类继承的是 ServletWebServerApplicationContext,这就是我们真正的主角,而这个类最终是继承了 AbstractApplicationContext,了解完创建上下文的情况后,我们再来看看刷新上下文,相关代码如下:

//类:SpringApplication.javaprivate void refreshContext(ConfigurableApplicationContext context) {//直接调用刷新方法refresh(context);if (this.registerShutdownHook) {try {context.registerShutdownHook();}catch (AccessControlException ex) {// Not allowed in some environments.}}}
//类:SpringApplication.javaprotected void refresh(ApplicationContext applicationContext) {Assert.isInstanceOf(AbstractApplicationContext.class, applicationContext);((AbstractApplicationContext) applicationContext).refresh();}

这里还是直接传递调用本类的 refresh(context)方法,最后是强转成父类 AbstractApplicationContext 调用其 refresh()方法,该代码如下:

// 类:AbstractApplicationContext
public void refresh() throws BeansException, IllegalStateException {synchronized (this.startupShutdownMonitor) {// Prepare this context for refreshing.prepareRefresh();// Tell the subclass to refresh the internal bean factory.ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();// Prepare the bean factory for use in this context.prepareBeanFactory(beanFactory);try {// Allows post-processing of the bean factory in context subclasses.postProcessBeanFactory(beanFactory);// Invoke factory processors registered as beans in the context.invokeBeanFactoryPostProcessors(beanFactory);// Register bean processors that intercept bean creation.registerBeanPostProcessors(beanFactory);// Initialize message source for this context.initMessageSource();// Initialize event multicaster for this context.initApplicationEventMulticaster();// Initialize other special beans in specific context subclasses.这里的意思就是调用各个子类的onRefresh()onRefresh();// Check for listener beans and register them.registerListeners();// Instantiate all remaining (non-lazy-init) singletons.finishBeanFactoryInitialization(beanFactory);// Last step: publish corresponding event.finishRefresh();}catch (BeansException ex) {if (logger.isWarnEnabled()) {logger.warn("Exception encountered during context initialization - " +"cancelling refresh attempt: " + ex);}// Destroy already created singletons to avoid dangling resources.destroyBeans();// Reset 'active' flag.cancelRefresh(ex);// Propagate exception to caller.throw ex;}finally {// Reset common introspection caches in Spring's core, since we// might not ever need metadata for singleton beans anymore...resetCommonCaches();}}}

这里我们看到 onRefresh()方法是调用其子类的实现,根据我们上文的分析,我们这里的子类是 ServletWebServerApplicationContext。

//类:ServletWebServerApplicationContext
protected void onRefresh() {super.onRefresh();try {createWebServer();}catch (Throwable ex) {throw new ApplicationContextException("Unable to start web server", ex);}}private void createWebServer() {WebServer webServer = this.webServer;ServletContext servletContext = getServletContext();if (webServer == null &amp;&amp; servletContext == null) {ServletWebServerFactory factory = getWebServerFactory();this.webServer = factory.getWebServer(getSelfInitializer());}else if (servletContext != null) {try {getSelfInitializer().onStartup(servletContext);}catch (ServletException ex) {throw new ApplicationContextException("Cannot initialize servlet context", ex);}}initPropertySources();}

到这里,其实庐山真面目已经出来了,createWebServer()就是启动 web 服务,但是还没有真正启动 Tomcat,既然 webServer 是通过 ServletWebServerFactory 来获取的,我们就来看看这个工厂的真面目。

6f74bd76dc4b2c6e588d05f170aeb4a4.png

走进 Tomcat 内部

根据上图我们发现,工厂类是一个接口,各个具体服务的实现是由各个子类来实现的,所以我们就去看看 TomcatServletWebServerFactory.getWebServer()的实现。

@Overridepublic WebServer getWebServer(ServletContextInitializer... initializers) {Tomcat tomcat = new Tomcat();File baseDir = (this.baseDirectory != null) ? this.baseDirectory : createTempDir("tomcat");tomcat.setBaseDir(baseDir.getAbsolutePath());Connector connector = new Connector(this.protocol);tomcat.getService().addConnector(connector);customizeConnector(connector);tomcat.setConnector(connector);tomcat.getHost().setAutoDeploy(false);configureEngine(tomcat.getEngine());for (Connector additionalConnector : this.additionalTomcatConnectors) {tomcat.getService().addConnector(additionalConnector);}prepareContext(tomcat.getHost(), initializers);return getTomcatWebServer(tomcat);}

根据上面的代码,我们发现其主要做了两件事情,第一件事就是把 Connnctor(我们称之为连接器)对象添加到 Tomcat 中,第二件事就是 configureEngine,这连接器我们勉强能理解(不理解后面会述说),那这个 Engine 是什么呢?我们查看 tomcat.getEngine()的源码:

public Engine getEngine() {Service service = getServer().findServices()[0];if (service.getContainer() != null) {return service.getContainer();}Engine engine = new StandardEngine();engine.setName( "Tomcat" );engine.setDefaultHost(hostname);engine.setRealm(createDefaultRealm());service.setContainer(engine);return engine;}

根据上面的源码,我们发现,原来这个 Engine 是容器,我们继续跟踪源码,找到 Container 接口

886919f99cf3bc36f16a83d09f9699e6.png

上图中,我们看到了 4 个子接口,分别是 Engine,Host,Context,Wrapper。我们从继承关系上可以知道他们都是容器,那么他们到底有啥区别呢?我看看他们的注释是怎么说的。

/**If used, an Engine is always the top level Container in a Catalina* hierarchy. Therefore, the implementation's <code>setParent()</code> method* should throw <code>IllegalArgumentException</code>.** @author Craig R. McClanahan*/
public interface Engine extends Container {//省略代码
}
/*** <p>* The parent Container attached to a Host is generally an Engine, but may* be some other implementation, or may be omitted if it is not necessary.* </p><p>* The child containers attached to a Host are generally implementations* of Context (representing an individual servlet context).** @author Craig R. McClanahan*/
public interface Host extends Container {
//省略代码}
/*** </p><p>* The parent Container attached to a Context is generally a Host, but may* be some other implementation, or may be omitted if it is not necessary.* </p><p>* The child containers attached to a Context are generally implementations* of Wrapper (representing individual servlet definitions).* </p><p>** @author Craig R. McClanahan*/
public interface Context extends Container, ContextBind {//省略代码
}
/**</p><p>* The parent Container attached to a Wrapper will generally be an* implementation of Context, representing the servlet context (and* therefore the web application) within which this servlet executes.* </p><p>* Child Containers are not allowed on Wrapper implementations, so the* <code>addChild()</code> method should throw an* <code>IllegalArgumentException</code>.** @author Craig R. McClanahan*/
public interface Wrapper extends Container {//省略代码
}

上面的注释翻译过来就是,Engine 是最高级别的容器,其子容器是 Host,Host 的子容器是 Context,Wrapper 是 Context 的子容器,所以这 4 个容器的关系就是父子关系,也就是 Engine>Host>Context>Wrapper。我们再看看 Tomcat 类的源码:

//部分源码,其余部分省略。
public class Tomcat {
//设置连接器public void setConnector(Connector connector) {Service service = getService();boolean found = false;for (Connector serviceConnector : service.findConnectors()) {if (connector == serviceConnector) {found = true;}}if (!found) {service.addConnector(connector);}}//获取servicepublic Service getService() {return getServer().findServices()[0];}//设置Host容器public void setHost(Host host) {Engine engine = getEngine();boolean found = false;for (Container engineHost : engine.findChildren()) {if (engineHost == host) {found = true;}}if (!found) {engine.addChild(host);}}//获取Engine容器public Engine getEngine() {Service service = getServer().findServices()[0];if (service.getContainer() != null) {return service.getContainer();}Engine engine = new StandardEngine();engine.setName( "Tomcat" );engine.setDefaultHost(hostname);engine.setRealm(createDefaultRealm());service.setContainer(engine);return engine;}//获取serverpublic Server getServer() {if (server != null) {return server;}System.setProperty("catalina.useNaming", "false");server = new StandardServer();initBaseDir();// Set configuration sourceConfigFileLoader.setSource(new CatalinaBaseConfigurationSource(new File(basedir), null));server.setPort( -1 );Service service = new StandardService();service.setName("Tomcat");server.addService(service);return server;}//添加Context容器public Context addContext(Host host, String contextPath, String contextName,String dir) {silence(host, contextName);Context ctx = createContext(host, contextPath);ctx.setName(contextName);ctx.setPath(contextPath);ctx.setDocBase(dir);ctx.addLifecycleListener(new FixContextListener());if (host == null) {getHost().addChild(ctx);} else {host.addChild(ctx);}//添加Wrapper容器public static Wrapper addServlet(Context ctx,String servletName,Servlet servlet) {// will do class for name and set init paramsWrapper sw = new ExistingStandardWrapper(servlet);sw.setName(servletName);ctx.addChild(sw);return sw;}}

阅读 Tomcat 的 getServer()我们可以知道,Tomcat 的最顶层是 Server,Server 就是 Tomcat 的实例,一个 Tomcat 一个 Server;通过 getEngine()我们可以了解到 Server 下面是 Service,而且是多个,一个 Service 代表我们部署的一个应用,而且我们还可以知道,Engine 容器,一个 service 只有一个;

根据父子关系,我们看 setHost()源码可以知道,host 容器有多个;同理,我们发现 addContext()源码下,Context 也是多个;addServlet()表明 Wrapper 容器也是多个,而且这段代码也暗示了,其实 Wrapper 和 Servlet 是一层意思。另外我们根据 setConnector 源码可以知道,连接器(Connector)是设置在 service 下的,而且是可以设置多个连接器(Connector)。

根据上面分析,我们可以小结下:Tomcat 主要包含了 2 个核心组件,连接器(Connector)和容器(Container),用图表示如下:

156c712e5f4faf394de866d8316370db.png

一个 Tomcat 是一个 Server,一个 Server 下有多个 service,也就是我们部署的多个应用,一个应用下有多个连接器(Connector)和一个容器(Container),容器下有多个子容器,关系用图表示如下:

8cbe2ca5766f02383d456c9fcab4a22d.png

Engine 下有多个 Host 子容器,Host 下有多个 Context 子容器,Context 下有多个 Wrapper 子容器。

总结

SpringBoot 的启动是通过 new SpringApplication()实例来启动的,启动过程主要做如下几件事情:> 1. 配置属性 > 2. 获取监听器,发布应用开始启动事件 > 3. 初始化输入参数 > 4. 配置环境,输出 banner > 5. 创建上下文 > 6. 预处理上下文 > 7. 刷新上下文 > 8. 再刷新上下文 > 9. 发布应用已经启动事件 > 10. 发布应用启动完成事件

而启动 Tomcat 就是在第 7 步中“刷新上下文”;Tomcat 的启动主要是初始化 2 个核心组件,连接器(Connector)和容器(Container),一个 Tomcat 实例就是一个 Server,一个 Server 包含多个 Service,也就是多个应用程序,每个 Service 包含多个连接器(Connetor)和一个容器(Container),而容器下又有多个子容器,按照父子关系分别为:Engine,Host,Context,Wrapper,其中除了 Engine 外,其余的容器都是可以有多个。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/442079.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

a1708硬盘转接口_资讯:希捷上架新款银河Exos系列机械硬盘,15000转+SAS协议

今日最新消息&#xff0c;希捷上架一款新品希捷银河Exos系列机械硬盘。据悉这款硬盘采用了SAS协议&#xff0c;转速高达15000RPM&#xff0c;目前公布的售价600GB为1899元RMB。据官方介绍这款希捷银河Exos系列机械硬盘为2.5英寸&#xff0c;15mm的厚度&#xff0c;最高的转速可…

腐蚀单机怎么进_暖气片堵塞是什么原因?要怎么解决呢?

你知道散热器到底为什么堵塞吗&#xff1f;散热器堵塞了怎么办&#xff1f;下面和金旗舰散热器小编一起来看看吧~一、散热器堵塞怎么办首先&#xff0c;把进回水阀先全部关闭&#xff0c;用扳手将散热器的堵头轻轻拧开。这里需要注意的是&#xff0c;堵头对应的散热器下面要放一…

vspy如何在图形面板显示报文_设备实时状态监控:如何进行工业生产设备数据采集?...

设备实时状态监控&#xff1a;如何进行工业生产设备数据采集&#xff1f;数据采集(DAQ)&#xff0c;是指从传感器和其它待测设备等模拟和数字被测单元中自动采集非电量或者电量信号,送到上位机中进行分析&#xff0c;处理。慧都设备数据采集系统解决方案工业生产设备数据采集是…

Sql Server数据库设置一个账户只能看到一个数据库

1 新建登录名&#xff0c;注意不要设置用户映射&#xff0c;服务器角色只选择public&#xff08;默认必选&#xff0c;无法去掉&#xff0c;可以添加其他服务器角色&#xff0c;但是不要添加查看所有数据库的权限&#xff0c;接下来会去掉public的查看所有数据库权限&#xff0…

如何在修改计算机设置时,不再弹出提示框?

1 打开控制面板&#xff0c;找到安全与维护&#xff1b; 2 进入安全与维护&#xff0c;在安全中找到“用户账户控制UAC”&#xff0c;点击打开“更改设置” 3 进行设置&#xff0c;“从不通知”设置之后&#xff0c;针对计算机的所有更改将不再提示

matlab两张图片合成一张_11. 图像合成与图像融合

本文同步发表在我的微信公众号“计算摄影学”&#xff0c;欢迎扫码关注【转载请注明来源和作者】我们终于进入了新的篇章。这一次我来给大家介绍一下图像合成与融合。我们经常看到一些很奇妙的PS技术&#xff0c;例如下面这张&#xff0c;它把1928年的一位叫做Frankie Yale的黑…

于小c三国语言_云顶之弈:三国成最强打工羁绊 校长教学顺滑转九五

虎牙校长是九五阵容的专业户&#xff0c;虽然版本在不断地更新&#xff0c;云顶的整体走向也在不断地发生变化&#xff0c;但九五至尊的强度一直都是TOP0级别&#xff0c;一旦成型第四保底&#xff0c;吃鸡都变得轻而易举。而整套九五的运营关键在于如何连胜、保证自身血量健康…

java null转换jason_常见java问题及解决办法汇总(干货可收藏)

Java Exception&#xff1a;1、Error2、Runtime Exception 运行时异常3、Exception4、throw 用户自定义异常异常类分两大类型&#xff1a;Error类代表了编译和系统的错误&#xff0c;不允许捕获&#xff1b;Exception类代表了标准Java库方法所激发的异常。Exception类还包含运行…

【HDU - 3038】How Many Answers Are Wrong (带权并查集--权为区间和)

题干&#xff1a;&#xff08;&#xff09; TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a s…

drop sqlite 多个表_SQLite简介与安装

SQLite简介&#xff1a;SQLite是一款轻型的数据库&#xff0c;是遵守ACID的关系型数据库管理系统&#xff0c;它包含在一个相对小的C库中&#xff0c;实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。就像其他数据库&#xff0c;SQLite 引擎不是一个独立的进…

【CF566#D】 Restructuring Company (并查集---合并区间操作)

题干&#xff1a; Even the most successful company can go through a crisis period when you have to make a hard decision — to restructure, discard and merge departments, fire employees and do other unpleasant stuff. Lets consider the following model of a c…

dg oracle 切换模式_谈谈dg切换涉及的概念:switchover和failover区别

概述今天有朋友问了一个问题&#xff1a;switchover和failover之间的区别&#xff0c;有点懵逼&#xff0c;居然把这忘记了&#xff0c;这里总结下两者之间的一些区别。DG架构DG切换时注意点&#xff1a;1、确认主库和从库间网络连接通畅&#xff1b;2、确认没有活动的会话连接…

gis影像格式img转为ecw_医学影像图片格式

&#xff08;1&#xff09;Analyze格式&#xff1a;Analyze格式储存的每组数据组包含2个文件&#xff0c;一个为数据文件&#xff0c;其扩展名为.img&#xff0c;包含二进制的图像资料&#xff1b;另外一个为头文件&#xff0c;扩展名为.hdr&#xff0c;包含图像的元数据。&…

case when then else多个条件_sqlserver条件分支case when使用教程

在sqlserver的条件分支case when有两种写法&#xff1a;1)case 字段 when 值 then 返回值 when 值2 then 返回值2 end2)case when 条件1 then 返回值1 when 条件2 then 返回值2 end方法步骤&#xff1a;1.打开“SQL Server Management Studio”管理工具&#xff0c;创建一张测试…

hashmap value占用空间大小_【Java集合框架002】原理层面:HashMap全解析

一、前言二、HashMap2.1 HashMap数据结构 HashMap线程不安全 哈希冲突2.1.1 HashMap数据结构学习的时候&#xff0c;先整体后细节&#xff0c;HashMap整体结构是 底层数组链表 &#xff0c;先记住&#xff0c;再开始看下面的HashMap相关知识点&#xff1a;底层数据结构&#…

升级bios_华硕B350PLUS升级BIOS更换AMD 3900X步骤

首先CPU更换看下面这张图&#xff0c;注意CPU上的小三角的位置。这块主板如果BIOS没有升级直接更换AMD 3900X的CPU会有点不亮显示器的问题&#xff0c;所以下面讲下华硕B350PLUS这块主板是如何更新到最新的BIOS驱动的(需要在原来老的CPU基础上先升级&#xff0c;升级完再更换39…

实体类 接口_spring-boot-route(五)整合Swagger生成接口文档

目前&#xff0c;大多数公司都采用了前后端分离的开发模式&#xff0c;为了解决前后端人员的沟通问题&#xff0c;后端人员在开发接口的时候会选择使用swagger2来生成对应的接口文档&#xff0c;swagger2提供了强大的页面调试功能&#xff0c;这样可以有效解决前后端人员沟通难…

bootstrap-table 新增可编辑行_现代Web开发堆栈工具DevExtreme 新增Gantt组件,助力项目管理...

点击“了解更多”获取DevExpress DevExtreme v19.2正式版下载DevExtreme拥有高性能的HTML5 / JavaScript小部件集合&#xff0c;使您可以利用现代Web开发堆栈(包括React&#xff0c;Angular&#xff0c;ASP.NET Core&#xff0c;jQuery&#xff0c;Knockout等)构建交互式的Web应…

关抢占 自旋锁_互斥锁、自旋锁、读写锁、悲观锁、乐观锁的应用场景

前言生活中用到的锁&#xff0c;用途都比较简单粗暴&#xff0c;上锁基本是为了防止外人进来、电动车被偷等等。但生活中也不是没有 BUG 的&#xff0c;比如加锁的电动车在「广西 - 窃格瓦拉」面前&#xff0c;锁就是形同虚设&#xff0c;只要他愿意&#xff0c;他就可以轻轻松…

dvwa详解_DVWA(六):XSSReflected 反射型XSS全等级详解

XSS 概念&#xff1a;由于web应用程序对用户的输入过滤不严&#xff0c;通过html注入篡改网页&#xff0c;插入恶意脚本&#xff0c;从而在用户浏览网页时&#xff0c;控制用户浏览器的一种攻击。XSS类型&#xff1a;Reflected(反射型)&#xff1a;只是简单的把用户输入的数据反…