spring mvc源码学习笔记之六

  • pom.xml 内容如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.qsm</groupId><artifactId>learn</artifactId><version>1.0.0</version></parent><groupId>com.qs.demo</groupId><artifactId>demo-077</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.3.28</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version><scope>provided</scope></dependency></dependencies></project>
  • com.qs.demo.MyWebApplicationInitializer 内容如下
package com.qs.demo;import com.qs.demo.root.AppConfig;
import com.qs.demo.sub.DispatcherConfig;import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;/*** @author qs* @date 2024/09/24*/
public class MyWebApplicationInitializer implements WebApplicationInitializer {// 这个例子来自于 WebApplicationInitializer 的文档@Overridepublic void onStartup(ServletContext container) {// Create the 'root' Spring application contextAnnotationConfigWebApplicationContext rootContext =new AnnotationConfigWebApplicationContext();rootContext.register(AppConfig.class);// Manage the lifecycle of the root application contextcontainer.addListener(new ContextLoaderListener(rootContext));// Create the dispatcher servlet's Spring application contextAnnotationConfigWebApplicationContext dispatcherContext =new AnnotationConfigWebApplicationContext();dispatcherContext.register(DispatcherConfig.class);// Register and map the dispatcher servletServletRegistration.Dynamic dispatcher =container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));dispatcher.setLoadOnStartup(1);// 一个 DispatcherServlet 包圆了所有的请求// 可以搞多个 DispatcherServlet 分别处理不同的请求dispatcher.addMapping("/");}
}
  • com.qs.demo.root.AppConfig 内容如下
package com.qs.demo.root;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;/*** @author qs* @date 2024/09/24*/
@Configuration
@ComponentScan("com.qs.demo.root")
public class AppConfig {}
  • com.qs.demo.root.AppleService 内容如下
package com.qs.demo.root;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;import java.util.UUID;/*** @author qs* @date 2024/09/24*/
@Service
public class AppleService implements ApplicationContextAware {private ApplicationContext applicationContext;public String a() {System.out.println(applicationContext);return UUID.randomUUID().toString();}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {this.applicationContext = applicationContext;}
}
  • com.qs.demo.sub.DispatcherConfig 内容如下
package com.qs.demo.sub;import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;/*** @author qs* @date 2024/09/24*/
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = "com.qs.demo.sub")
public class DispatcherConfig {}
  • com.qs.demo.sub.BananaService 内容如下
package com.qs.demo.sub;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;import java.util.UUID;/*** @author qs* @date 2024/09/24*/
@Service
public class BananaService implements ApplicationContextAware {public String a() {return UUID.randomUUID().toString();}@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {System.out.println(applicationContext);}
}
  • com.qs.demo.sub.Demo01Controller 内容如下
package com.qs.demo.sub;import com.qs.demo.root.AppleService;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;import javax.annotation.Resource;/*** @author qs* @date 2024/09/24*/
@RestController
public class Demo01Controller {@Resource private AppleService appleService;@Resource private BananaService bananaService;@GetMapping("/01")public String a() {return "01";}@GetMapping("/02")public String b() {return appleService.a();}@GetMapping("/03")public String c() {return bananaService.a();}
}

以上就是全部代码

写这个例子主要是为了介绍 WebApplicationInitializer 这个接口。简单点儿讲就是这个接口等价于 web.xml 这个配置文件。
写了这个接口就不用写 web.xml 配置文件了。
下面重点看下这个接口的 javadoc

/**  
* <p>
* 下面这段话的关键点:
* 1、适用于 servlet 3.0+ 环境
* 2、该接口可以看做是传统的 web.xml 的替代品
* </p>
*
* Interface to be implemented in Servlet 3.0+ environments in order to configure the  
* {@link ServletContext} programmatically -- as opposed to (or possibly in conjunction  
* with) the traditional {@code web.xml}-based approach.  
*
* <p>
* 下面这段话的意思:
* 1、该接口的实现会自动被 SpringServletContainerInitializer 检测到
* 2、而 SpringServletContainerInitializer 又会被 servlet 3.0 容器自动带起来
* </p>
*
* <p>Implementations of this SPI will be detected automatically by {@link  
* SpringServletContainerInitializer}, which itself is bootstrapped automatically  
* by any Servlet 3.0 container. See {@linkplain SpringServletContainerInitializer its  
* Javadoc} for details on this bootstrapping mechanism.  
*
* <p>注意下面这个例子。看本接口是怎样替换 web.xml 配置的</p>
*
* <h2>Example</h2>  
* <h3>The traditional, XML-based approach</h3>  
* Most Spring users building a web application will need to register Spring's {@code  
* DispatcherServlet}. For reference, in WEB-INF/web.xml, this would typically be done as  
* follows:  
* <pre class="code">  
* {@code  
* <servlet>  
* <servlet-name>dispatcher</servlet-name>  
* <servlet-class>  
* org.springframework.web.servlet.DispatcherServlet  
* </servlet-class>  
* <init-param>  
* <param-name>contextConfigLocation</param-name>  
* <param-value>/WEB-INF/spring/dispatcher-config.xml</param-value>  
* </init-param>  
* <load-on-startup>1</load-on-startup>  
* </servlet>  
*  
* <servlet-mapping>  
* <servlet-name>dispatcher</servlet-name>  
* <url-pattern>/</url-pattern>  
* </servlet-mapping>}</pre>  
*  
* <h3>The code-based approach with {@code WebApplicationInitializer}</h3>  
* Here is the equivalent {@code DispatcherServlet} registration logic,  
* {@code WebApplicationInitializer}-style:  
* <pre class="code">  
* public class MyWebAppInitializer implements WebApplicationInitializer {  
*  
* &#064;Override  
* public void onStartup(ServletContext container) {  
* XmlWebApplicationContext appContext = new XmlWebApplicationContext();  
* appContext.setConfigLocation("/WEB-INF/spring/dispatcher-config.xml");  
*  
* ServletRegistration.Dynamic dispatcher =  
* container.addServlet("dispatcher", new DispatcherServlet(appContext));  
* dispatcher.setLoadOnStartup(1);  
* dispatcher.addMapping("/");  
* }  
*  
* }</pre>  
*
* <p>
* 上面的例子是实现 WebApplicationInitializer 接口。
* 也可以继承 AbstractDispatcherServletInitializer 类。
* </p>
*
* As an alternative to the above, you can also extend from {@link  
* org.springframework.web.servlet.support.AbstractDispatcherServletInitializer}.  
*  
* As you can see, thanks to Servlet 3.0's new {@link ServletContext#addServlet} method  
* we're actually registering an <em>instance</em> of the {@code DispatcherServlet}, and  
* this means that the {@code DispatcherServlet} can now be treated like any other object  
* -- receiving constructor injection of its application context in this case.  
*  
* <p>This style is both simpler and more concise. There is no concern for dealing with  
* init-params, etc, just normal JavaBean-style properties and constructor arguments. You  
* are free to create and work with your Spring application contexts as necessary before  
* injecting them into the {@code DispatcherServlet}.  
*  
* <p>Most major Spring Web components have been updated to support this style of  
* registration. You'll find that {@code DispatcherServlet}, {@code FrameworkServlet},  
* {@code ContextLoaderListener} and {@code DelegatingFilterProxy} all now support  
* constructor arguments. Even if a component (e.g. non-Spring, other third party) has not  
* been specifically updated for use within {@code WebApplicationInitializers}, they still  
* may be used in any case. The Servlet 3.0 {@code ServletContext} API allows for setting  
* init-params, context-params, etc programmatically.  
*
* <p>
* 在上面的例子中,web.xml 被替换了,但是 dispatcher-config.xml 依然存在。
* 下面的例子就彻底摆脱 xml 配置了。
* </p>
*
* <h2>A 100% code-based approach to configuration</h2>  
* In the example above, {@code WEB-INF/web.xml} was successfully replaced with code in  
* the form of a {@code WebApplicationInitializer}, but the actual  
* {@code dispatcher-config.xml} Spring configuration remained XML-based.  
* {@code WebApplicationInitializer} is a perfect fit for use with Spring's code-based  
* {@code @Configuration} classes. See @{@link  
* org.springframework.context.annotation.Configuration Configuration} Javadoc for  
* complete details, but the following example demonstrates refactoring to use Spring's  
* {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext  
* AnnotationConfigWebApplicationContext} in lieu of {@code XmlWebApplicationContext}, and  
* user-defined {@code @Configuration} classes {@code AppConfig} and  
* {@code DispatcherConfig} instead of Spring XML files. This example also goes a bit  
* beyond those above to demonstrate typical configuration of the 'root' application  
* context and registration of the {@code ContextLoaderListener}:  
* <pre class="code">  
* public class MyWebAppInitializer implements WebApplicationInitializer {  
*  
* &#064;Override  
* public void onStartup(ServletContext container) {  
* // Create the 'root' Spring application context  
* AnnotationConfigWebApplicationContext rootContext =  
* new AnnotationConfigWebApplicationContext();  
* rootContext.register(AppConfig.class);  
*  
* // Manage the lifecycle of the root application context  
* container.addListener(new ContextLoaderListener(rootContext));  
*  
* // Create the dispatcher servlet's Spring application context  
* AnnotationConfigWebApplicationContext dispatcherContext =  
* new AnnotationConfigWebApplicationContext();  
* dispatcherContext.register(DispatcherConfig.class);  
*  
* // Register and map the dispatcher servlet  
* ServletRegistration.Dynamic dispatcher =  
* container.addServlet("dispatcher", new DispatcherServlet(dispatcherContext));  
* dispatcher.setLoadOnStartup(1);  
* dispatcher.addMapping("/");  
* }  
*  
* }</pre>  
*  
* As an alternative to the above, you can also extend from {@link  
* org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer}.  
*  
* Remember that {@code WebApplicationInitializer} implementations are <em>detected  
* automatically</em> -- so you are free to package them within your application as you  
* see fit.  
*
* <p>
* 多个 WebApplicationInitializer 之间可以指定顺序。但是这种一般不常用。一个 WebApplicationInitializer 就够了。
* </p>
*
* <h2>Ordering {@code WebApplicationInitializer} execution</h2>  
* {@code WebApplicationInitializer} implementations may optionally be annotated at the  
* class level with Spring's @{@link org.springframework.core.annotation.Order Order}  
* annotation or may implement Spring's {@link org.springframework.core.Ordered Ordered}  
* interface. If so, the initializers will be ordered prior to invocation. This provides  
* a mechanism for users to ensure the order in which servlet container initialization  
* occurs. Use of this feature is expected to be rare, as typical applications will likely  
* centralize all container initialization within a single {@code WebApplicationInitializer}.  
*  
* <h2>Caveats</h2>  
*
* <p>
* 注意 web.xml 和 WebApplicationInitializer 不是相互排斥的。
* 二者可以同时存在。
* </p>
*
* <h3>web.xml versioning</h3>  
* <p>{@code WEB-INF/web.xml} and {@code WebApplicationInitializer} use are not mutually  
* exclusive; for example, web.xml can register one servlet, and a {@code  
* WebApplicationInitializer} can register another. An initializer can even  
* <em>modify</em> registrations performed in {@code web.xml} through methods such as  
* {@link ServletContext#getServletRegistration(String)}. <strong>However, if  
* {@code WEB-INF/web.xml} is present in the application, its {@code version} attribute  
* must be set to "3.0" or greater, otherwise {@code ServletContainerInitializer}  
* bootstrapping will be ignored by the servlet container.</strong>  
*  
* <h3>Mapping to '/' under Tomcat</h3>  
* <p>Apache Tomcat maps its internal {@code DefaultServlet} to "/", and on Tomcat versions  
* &lt;= 7.0.14, this servlet mapping <em>cannot be overridden programmatically</em>.  
* 7.0.15 fixes this issue. Overriding the "/" servlet mapping has also been tested  
* successfully under GlassFish 3.1.<p>  
*  
* @author Chris Beams  
* @since 3.1  
* @see SpringServletContainerInitializer  
* @see org.springframework.web.context.AbstractContextLoaderInitializer  
* @see org.springframework.web.servlet.support.AbstractDispatcherServletInitializer  
* @see org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer  
*/ 

多说一嘴,这个例子中用到了 DispatcherServlet 的有参构造(DispatcherServlet只有2个构造方法,一个无参一个有参,无参构造在其他文章中介绍了)。
这里就顺便详细看下这个有参构造的 javadoc

/*** 使用给定的 web 应用上下文来创建一个 DispatcherServlet。* 无参的构造是在 DispatcherServlet 内部自己创建维护 web 应用上下文。* 这个有参的构造是用外部传过来的 web 应用上下文。* 这个构造方法主要是用在 servlet 3.0+ 的环境中。* 用了这个构造方法以后,setContextClass setContextConfigLocation setContextAttribute setNamespace 这4个方法就无效了。* 对应的 contextClass contextConfigLocation contextAttribute namespace 等四个 servlet init-param 也无效了。* 传进来的 web 应用上下文可能已经 refresh() 了,也可能没有 refresh()。* 建议是不要 refresh()。* 如果不刷新的话,将会发生这些事情:* 1、如果传进来的web应用上下文还没有设置父应用上下文,则将 root web 应用上下文设置为它的父应用上下文。* 2、如果传进来的web应用上下文还没有设置id,将会给它设置一个id。* 3、将ServletContext和ServletConfig存到web应用上下文中。* 4、postProcessWebApplicationContext 方法会被调用。* 5、ApplicationContextInitializer 会被调用。可以用这个东西对web应用上下文进行自定义配置,其他文章也有提过。* 6、如果传进来的web应用上下文实现了ConfigurableApplicationContext的话,refresh()方法将会被调用。* 如果传进来的web应用上下文已经 refresh() 过了,上面提到的几点都不会发生。* * 另外,这个有参构造怎么用,可以参考 WebApplicationInitializer 接口。这不就跟本文写的代码对应上了么。** Create a new {@code DispatcherServlet} with the given web application context. This* constructor is useful in Servlet 3.0+ environments where instance-based registration* of servlets is possible through the {@link ServletContext#addServlet} API.* <p>Using this constructor indicates that the following properties / init-params* will be ignored:* <ul>* <li>{@link #setContextClass(Class)} / 'contextClass'</li>* <li>{@link #setContextConfigLocation(String)} / 'contextConfigLocation'</li>* <li>{@link #setContextAttribute(String)} / 'contextAttribute'</li>* <li>{@link #setNamespace(String)} / 'namespace'</li>* </ul>* <p>The given web application context may or may not yet be {@linkplain* ConfigurableApplicationContext#refresh() refreshed}. If it has <strong>not</strong>* already been refreshed (the recommended approach), then the following will occur:* <ul>* <li>If the given context does not already have a {@linkplain* ConfigurableApplicationContext#setParent parent}, the root application context* will be set as the parent.</li>* <li>If the given context has not already been assigned an {@linkplain* ConfigurableApplicationContext#setId id}, one will be assigned to it</li>* <li>{@code ServletContext} and {@code ServletConfig} objects will be delegated to* the application context</li>* <li>{@link #postProcessWebApplicationContext} will be called</li>* <li>Any {@code ApplicationContextInitializer}s specified through the* "contextInitializerClasses" init-param or through the {@link* #setContextInitializers} property will be applied.</li>* <li>{@link ConfigurableApplicationContext#refresh refresh()} will be called if the* context implements {@link ConfigurableApplicationContext}</li>* </ul>* If the context has already been refreshed, none of the above will occur, under the* assumption that the user has performed these actions (or not) per their specific* needs.* <p>See {@link org.springframework.web.WebApplicationInitializer} for usage examples.* @param webApplicationContext the context to use* @see #initWebApplicationContext* @see #configureAndRefreshWebApplicationContext* @see org.springframework.web.WebApplicationInitializer*/
public DispatcherServlet(WebApplicationContext webApplicationContext) {super(webApplicationContext);setDispatchOptionsRequest(true);
}

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

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

相关文章

云备份项目--服务端编写

文章目录 7. 数据管理模块7.1 如何设计7.2 完整的类 8. 热点管理8.1 如何设计8.2 完整的类 9. 业务处理模块9.1 如何设计9.2 完整的类9.3 测试9.3.1 测试展示功能 完整的代码–gitee链接 7. 数据管理模块 TODO: 读写锁&#xff1f;普通锁&#xff1f; 7.1 如何设计 需要管理…

flutter在windows平台中运行报错

PS D:\F\luichun> flutter run当运行flutter项目时&#xff0c;【解决如下报错】 /C:/flutter/packages/flutter/lib/src/painting/star_border.dart:530:27: Error: The getter Matrix4 isnt defined for the class _StarGenerator.- _StarGenerator is from package:flut…

Synthesia技术浅析(二):虚拟人物视频生成

Synthesia 的虚拟人物视频生成模块是其核心技术之一&#xff0c;能够将文本输入转换为带有同步语音和口型的虚拟人物视频。该模块如下所示&#xff1a; 1.文本输入处理 2.语音生成&#xff08;TTS, Text-to-Speech&#xff09; 3.口型同步&#xff08;Lip Syncing&#xff0…

[Linux]进程间通信-共享内存与消息队列

目录 一、共享内存 1.共享内存的原理 2.共享内存的接口 命令行 创建共享内存 共享内存的挂接 去掉挂接 共享内存的控制 3.共享内存的使用代码 Comm.hpp--封装了操作接口 客户端--写入端 服务器--读取端 4.管道实现共享内存的同步机制 二、消息队列 1.底层原理 2…

凸包(convex hull)简述

凸包&#xff08;convex hull&#xff09;简述 这里主要介绍二维凸包&#xff0c;二维凸多边形是指所有内角都在 [ 0 , Π ] [0,\Pi ] [0,Π]范围内的简单多边形。 凸包是指在平面上包含所有给定点的最小凸多边形。 数学定义&#xff1a;对于给定集合 X X X&#xff0c;所有…

【ArcGISPro/GeoScenePro】检查多光谱影像的属性并优化其外观

数据 https://arcgis.com/sharing/rest/content/items/535efce0e3a04c8790ed7cc7ea96d02d/data 操作 其他数据 检查影像的属性 熟悉检查您正在使用的栅格属性非常重要。

提升汽车金融租赁系统的效率与风险管理策略探讨

内容概要 在汽车金融租赁系统这个复杂的生态中&#xff0c;提升整体效率是每个企业都渴望达成的目标。首先&#xff0c;优化业务流程是实现高效运行的基础。通过分析目前的流程&#xff0c;找出冗余环节并进行简化&#xff0c;能够帮助企业缩短审批时间&#xff0c;提高客户满…

以太网UDP协议栈实现(支持ARP、ICMP、UDP)--FPGA学习笔记26

纯verilog实现&#xff0c;仅使用锁相环IP、FIFO IP&#xff0c;方便跨平台移植。支持ping指令。 以太网系列文章&#xff1a; 以太网ICMP协议(ping指令)——FPGA学习笔记25-CSDN博客 以太网ARP协议——FPGA学习笔记23-CSDN博客 以太网PHY_MDIO通信&#xff08;基于RTL821…

edeg插件/扩展推荐:助力生活工作

WeTab 此插件在我看来有2个作用 1.改变edeg的主页布局和样式,使其更加精简,无广告 2.提供付费webtab Ai(底层是chatGpt) 沉浸式翻译 此插件可翻译网页的内容 假设我们浏览github 翻译前 翻译后 Better Ruler 可以对网页的距离进行测量 适合写前端的小伙伴 用法示例:

java项目之校园管理系统的设计与实现(源码+文档)

风定落花生&#xff0c;歌声逐流水&#xff0c;大家好我是风歌&#xff0c;混迹在java圈的辛苦码农。今天要和大家聊的是一款基于springboot的校园管理系统的设计与实现。项目源码以及部署相关请联系风歌&#xff0c;文末附上联系信息 。 项目简介&#xff1a; springboot校园…

设计模式 结构型 适配器模式(Adapter Pattern)与 常见技术框架应用 解析

适配器模式&#xff08;Adapter Pattern&#xff09;是一种结构型设计模式&#xff0c;它允许将一个类的接口转换成客户端所期望的另一个接口&#xff0c;从而使原本因接口不兼容而无法一起工作的类能够协同工作。这种设计模式在软件开发中非常有用&#xff0c;尤其是在需要集成…

打造三甲医院人工智能矩阵新引擎(一):文本大模型篇--基于GPT-4o的探索

一、引言 当今时代,人工智能技术正以前所未有的速度蓬勃发展,深刻且广泛地渗透至各个领域,医疗行业更是这场变革的前沿阵地。在人口老龄化加剧、慢性疾病患病率上升以及人们对健康需求日益增长的大背景下,三甲医院作为医疗体系的核心力量,承担着极为繁重且复杂的医疗任务。…

S7-200采集频率信号

S7-200可以借助高速计数器完成频率信号采集&#xff0c;接入流量计、转速等信号。官方给出的程序块无法完成多路同时采集&#xff0c;需要自己进行修改。 首先下载官方的频率采集库 SIOS 下载后导入library&#xff0c;在library中出现Frequency(v1.0) 拖进ladder后&#xf…

专家混合(MoE)大语言模型:免费的嵌入模型新宠

专家混合&#xff08;MoE&#xff09;大语言模型&#xff1a;免费的嵌入模型新宠 今天&#xff0c;我们深入探讨一种备受瞩目的架构——专家混合&#xff08;Mixture-of-Experts&#xff0c;MoE&#xff09;大语言模型&#xff0c;它在嵌入模型领域展现出了独特的魅力。 一、M…

【Vue】分享一个快速入门的前端框架以及如何搭建

先上效果图: 登录 菜单: 下载地址: 链接&#xff1a;https://pan.baidu.com/s/1m-ZlBARWU6_2n8jZil_RAQ 提取码&#xff1a;ui20 … 主要是可以自定义设置token,更改后端请求地址较为方便。 应用设置: 登录与token设置: 在这里设置不用登录,可以请求的接口: request.js i…

MySQL叶子节点为啥使用双向链表?不使用单向呢?

文章内容收录到个人网站&#xff0c;方便阅读&#xff1a;http://hardyfish.top/ 文章内容收录到个人网站&#xff0c;方便阅读&#xff1a;http://hardyfish.top/ 文章内容收录到个人网站&#xff0c;方便阅读&#xff1a;http://hardyfish.top/ MySQL 中的 B 树索引&#x…

用户界面的UML建模10

非正常的可视反馈可伴随着同步事件发生&#xff0c;而同步事件可由系统动作产生。但是&#xff0c;可以分别对它们进行建模。 在下节中将对这些特殊的事件依次进行论述。 6.1 异常处理建模 异常&#xff0c;由Meyer 定义[16],其作为运行时事件&#xff08;run-time events&a…

最新版Chrome浏览器加载ActiveX控件之CFCA安全输入控件

背景 CFCA安全输入控件用于保证用户在浏览器、桌面客户端、移动客户端中输入信息的安全性&#xff0c;防止运行在用户系统上的病毒、木马等恶意程序入侵窃取用户输入的敏感信息。确保用户输入、本地缓存、网络传输整个流程中&#xff0c;输入的敏感信息不被窃取。广泛应用于银行…

0基础跟德姆(dom)一起学AI 自然语言处理10-LSTM模型

1 LSTM介绍 LSTM&#xff08;Long Short-Term Memory&#xff09;也称长短时记忆结构, 它是传统RNN的变体, 与经典RNN相比能够有效捕捉长序列之间的语义关联, 缓解梯度消失或爆炸现象. 同时LSTM的结构更复杂, 它的核心结构可以分为四个部分去解析: 遗忘门输入门细胞状态输出门…

力扣283 移动零

void moveZeroes(int* nums, int numsSize) {int last_non_zero_found_at 0;for (int i 0; i < numsSize; i) {if (nums[i] ! 0) {// 交换 nums[last_non_zero_found_at] 和 nums[i]int temp nums[last_non_zero_found_at];nums[last_non_zero_found_at] nums[i];nums[i…