SpringBoot第二天

目录

1.Web开发

1.1简介

1.2SpringBoot对静态资源的映射规则

1.3模板引擎

1.3.1引入thymeleaf;

1.3.2Thymeleaf语法

1.3.2.1标准表达式语法

        1.变量表达式

1.3.2.2表达式支持的语法

1.3.2.3常用的thymeleaf标签

1.4Springboot整合springmvc

1.4.1Springmvc的自动解管理

1.4.1.1中央转发器

1.4.1.2控制器

1.4.1.3视图解析器自动管理

1.4.1.4静态资源访问

1.4.1.5消息转换和格式化

1.4.1.6欢迎页面的自动配置

1.4.2Springboot扩展springmvc 

1.4.2.1在容器中注册视图控制器(请求转发)

1.4.2.2注册格式化器

1.4.2.3消息转换器扩展fastjson

1.4.2.4拦截器注册

1.5配置嵌入式服务器

1.5.1如何定制和修改Servlet容器的相关配置;

1.5.2注册Servlet三大组件【Servlet、Filter、Listener】

1.6使用外置的Servlet容器


1.Web开发

1.1简介

使用SpringBoot
1)、创建SpringBoot应用,选中我们需要的模块;
2)、SpringBoot已经默认将这些场景配置好了,只需要在配置文件中指定少量配置就可以运行起来
3)、自己编写业务代码;

自动配置原理?
这个场景SpringBoot帮我们配置了什么?能不能修改?能修改哪些配置?能不能扩展?xxx

1.2SpringBoot对静态资源的映射规则

@ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
public class ResourceProperties implements ResourceLoaderAware {
//可以设置和静态资源有关的参数,缓存时间等
WebMvcAuotConfiguration:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {if (!this.resourceProperties.isAddMappings()) {logger.debug("Default resource handling disabled");return;} 
Integer cachePeriod = this.resourceProperties.getCachePeriod();
if (!registry.hasMappingForPattern("/webjars/**")) {customizeResourceHandlerRegistration(registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META‐INF/resources/webjars/").setCachePeriod(cachePeriod));
} 
String staticPathPattern = this.mvcProperties.getStaticPathPattern();
//静态资源文件夹映射
if (!registry.hasMappingForPattern(staticPathPattern)) {customizeResourceHandlerRegistration(registry.
addResourceHandler(staticPathPattern).addResourceLocations(this.resourceProperties.getStaticLocations()).setCachePeriod(cachePeriod));
}
} /
/配置欢迎页映射
@Bean
public WelcomePageHandlerMapping welcomePageHandlerMapping(ResourceProperties resourceProperties) {return new WelcomePageHandlerMapping(resourceProperties.getWelcomePage(),
this.mvcProperties.getStaticPathPattern());
}
//配置喜欢的图标
@Configuration
@ConditionalOnProperty(value = "spring.mvc.favicon.enabled", matchIfMissing = true)
public static class FaviconConfiguration {private final ResourceProperties resourceProperties;public FaviconConfiguration(ResourceProperties resourceProperties) {this.resourceProperties = resourceProperties;
}@Bean
public SimpleUrlHandlerMapping faviconHandlerMapping() {SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();mapping.setOrder(Ordered.HIGHEST_PRECEDENCE + 1);//所有 **/favicon.icomapping.setUrlMap(Collections.singletonMap("**/favicon.ico",
faviconRequestHandler());
return mapping;
} 
@Bean
public ResourceHttpRequestHandler faviconRequestHandler() {ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler();requestHandler.setLocations(this.resourceProperties.getFaviconLocations());return requestHandler;}
}

1)、所有 /webjars/** ,都去 classpath:/META-INF/resources/webjars/ 找资源;

webjars:以jar包的方式引入静态资源;WebJars - Web Libraries in Jars

 

        localhost:8080/webjars/jquery/3.3.1/jquery.js 

<!‐‐引入jquery‐webjar‐‐>在访问的时候只需要写webjars下面资源的名称即可
<dependency><groupId>org.webjars</groupId><artifactId>jquery</artifactId><version>3.3.1</version>
</dependency>

2)、"/**" 访问当前项目的任何资源,都去(静态资源的文件夹)找映射

"classpath:/META‐INF/resources/",
"classpath:/resources/",
"classpath:/static/",
"classpath:/public/"
"/":当前项目的根路径

localhost:8080/abc === 去静态资源文件夹里面找abc

3)、欢迎页; 静态资源文件夹下的所有index.html页面;被"/**"映射;

localhost:8080/ index页面

1.3模板引擎

JSPVelocityFreemarkerThymeleaf

SpringBoot推荐的Thymeleaf

语法更简单,功能更强大;

1.3.1引入thymeleaf

        在pom.xml中引入

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

        从spring父文件中能看到Springboot2.0.1所使用的thymeleaf版本是3.0.9

        springBoot启动的时候会自动配置

org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration

        从ThymeleafAutoConfiguration的源代码中我们可以得知ThymeleafProperties中配置了Thymeleaf的规则

public class ThymeleafProperties {private static final Charset DEFAULT_ENCODING;public static final String DEFAULT_PREFIX = "classpath:/templates/";public static final String DEFAULT_SUFFIX = ".html";private boolean checkTemplate = true;private boolean checkTemplateLocation = true;private String prefix = "classpath:/templates/";private String suffix = ".html";private String mode = "HTML";private Charset encoding;private boolean cache;
}

我们使用html作为模板,而且默认的前缀是放在classpath:/templates/下,后缀是.html

当然这些属性我们都可以通过application.properties来修改我们采用默认即可。

示例

  1. templates下创建一个success.html
  2. html中引入thymeleaf的命名空间
    <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. 创建一个Controller提供一个访问的方法
    @RequestMapping("/success")
    public String hello(Model model){model.addAttribute("hello","<h1>zhangsan</h1>");return "success";
    }
  4. thymeleaf模板中取值
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en" xmlns:th="http://www.thymeleaf.org">
    <head><title>Title</title>
    </head>
    <body>
    <div  th:text="${hello}"> </div>
    </body>
    </html>

1.3.2Thymeleaf语法

1.3.2.1标准表达式语法
        1.变量表达式

变量表达式即OGNL表达式或Spring EL表达式(Spring术语中也叫model attributes)。如下所示: ${session.user.name}

它们将以HTML标签的一个属性来表示:

<span th:text="${book.author.name}"> 

        2.选择(星号)表达式

        选择表达式很像变量表达式,不过它们用一个预先选择的对象来代替上下文变量容器(map)来执行,如下: *{customer.name}

        被指定的objectth:object属性定义:

<div th:object="${book}"> ... <span th:text="*{title}">...</span> ... 
</div>

        3.文字国际化表达式

        文字国际化表达式允许我们从一个外部文件获取区域文字信息(.properties),用Key索引Value,还可以提供一组参数(可选).

#{main.title}

        4.URL表达式

URL表达式指的是把一个有用的上下文或回话信息添加到URL,这个过程经常被叫做URL重写。不需要指定项目名字
@{/order/list} 

URL还可以设置参数:

@{/order/details(id=${orderId})} 

让我们看这些表达式:

<form th:action="@{/createOrder}"> 
<a href="main.html" rel="external nofollow" th:href="@{/main}" rel="external n
1.3.2.2表达式支持的语法

字面(Literals)

  • 文本文字(Text literals): 'one text', 'Another one!',…
  • 数字文本(Number literals): 0, 34, 3.0, 12.3,…
  • 布尔文本(Boolean literals): true, false
  • 空(Null literal): null
  • 文字标记(Literal tokens): one, sometext, main,…

文本操作(Text operations)

  • 字符串连接(String concatenation): +
  • 文本替换(Literal substitutions): |The name is ${name}|

算术运算(Arithmetic operations)

  • 二元运算符(Binary operators): +, -, *, /, %
  • 减号(单目运算符)Minus sign (unary operator): -

布尔操作(Boolean operations)

  • 二元运算符(Binary operators):and, or
  • 布尔否定(一元运算符)Boolean negation (unary operator):!, not

比较和等价(Comparisons and equality)

  • 比较(Comparators): >, <, >=, <= (gt, lt, ge, le)
  • 等值运算符(Equality operators):==, != (eq, ne)

条件运算符(Conditional operators)

If-then: (if) ? (then)

If-then-else: (if) ? (then) : (else)

Default: (value) ?: (defaultvalue)

示例代码

'User is of type ' + (${user.isAdmin()} ? 'Administrator' : (${user.type} ?: 'Unknown'))

1.3.2.3常用的thymeleaf标签

关键字

功能介绍

案例

th:id

替换id

<input th:id="'xxx' + ${collect.id}"/>

th:text

文本替换

<p th:text="${collect.description}">description</p>

th:utext

支持html的文本替换

<p th:utext="${htmlcontent}">conten</p>

th:object

替换对象

<div th:object="${session.user}">

th:value

属性赋值

<input th:value="${user.name}" />

th:onclick

点击事件

th:οnclick="'getCollect()'"

th:each

属性赋值

tr th:each="user,userStat:${users}">

th:if

判断条件

<a th:if="${userId == collect.userId}" >

th:unless

和th:if判断相反

<a th:href="@{/login}" rel="external nofollow" rel="external nofollow" rel="external nofollow" th:unless=${session.user != null}>Login</a>

th:href

链接地址

<a th:href="@{/login}" rel="external nofollow" rel="external nofollow" rel="external nofollow" th:unless=${session.user != null}>Login</a> />

th:switch

多路选择 配合th:case 使用

<div th:switch="${user.role}">

th:case

th:switch的一个分支

<p th:case="'admin'">User is an administrator</p>

th:fragment

布局标签,定义一个代码片段,方便其它地方引用

<div th:fragment="alert">

th:include

布局标签,替换内容到引入的文件

<head th:include="layout :: htmlhead" th:with="title='xx'"></head> />

th:replace

布局标签,替换整个标签到引入的文件

<div th:replace="fragments/header :: title"></div>

th:selected

selected选择框 选中

th:selected="(${xxx.id} == ${configObj.dd})"

th:src

图片类地址引入

<img class="img-responsive" alt="App Logo" th:src="@{/img/logo.png}" />

th:action

表单提交的地址

<form action="subscribe.html" th:action="@{/subscribe}">

        标签测试

        模板:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head><title>Title</title>
</head>
<body>
<div  th:text="${hello}" th:id="${hello.toUpperCase()}">xxxx</div>
<input th:value="${user.getUsername()}">
<hr>
<div th:object="${user}">
<span th:text="*{username}"></span></div><a th:href="" th:if="${user.getAge() == 2}" >年龄</a><a  th:class="${user.getAge() > 2}?'class1':'class2'" >年龄</a><p th:if="${user.score >= 60 and user.score < 85}">B</p>
<p th:if="${user.score < 60}">C</p>
<p th:if="${user.score > 85}">优秀</p><span th:switch="${user.gender}"><p th:case="1">男</p><p th:case="2">女</p>
</span><table><tr th:each="a,aState:${uList}"><td th:text="${a.username}"></td><td th:text="${a.password}"></td><td th:text="${aState.index}"></td></tr>
</table></body>
</html>

        Controller中给数据

@RequestMapping("/success")
public String hello(HttpServletRequest req, HttpSession httpSession, Model model){model.addAttribute("hello","<h1>renliang</h1>");User user = new User();user.setPassword("111");user.setUsername("renliang");user.setAge(1);user.setScore(78);user.setGender(2);List<User> uList = new ArrayList<>();for (int i = 0; i < 10; i++){User u = new User();u.setUsername("renliang"+i);u.setPassword("111"+i);uList.add(u);}// httpSession.setAttribute("user", user);model.addAttribute("user", user);model.addAttribute("uList", uList);return "success";
}

1.4Springboot整合springmvc

    https://docs.spring.io/spring-boot/docs/2.0.2.RELEASE/reference/htmlsingle/#boot-features-spring-mvc

        学习springmvc和springboot的自动配置我们必须对springmvc的组件足够了解,起码知道怎么用。Springmvc的组件基本都被springboot来做了自动的配置。

1.4.1Springmvc的自动解管理

  1. 中央转发器(DispatcherServlet
  2. 控制器
  3. 视图解析器
  4. 静态资源访问
  5. 消息转换器
  6. 格式化
  7. 静态资源管理
  8. 1.4.1.1中央转发器
    1.         Xml无需配置

      1. <servlet><servlet-name>chapter2</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping><servlet-name>chapter2</servlet-name><url-pattern>/</url-pattern>
        </servlet-mapping>

                中央转发器被springboot自动接管,不再需要我们在web.xml中配置,我们现在的项目也不是web项目,也不存在web.xml,

        org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration,\

1.4.1.2控制器

        控制器Controller在springboot的注解扫描范围内自动管理。

1.4.1.3视图解析器自动管理

Inclusion of ContentNegotiatingViewResolver and BeanNameViewResolver beans.

ContentNegotiatingViewResolver:组合所有的视图解析器的;

曾经的配置文件无需再配

<bean id="de" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/"></property>
    <property name="suffix" value="*.jsp"></property>
</bean>

        源码:

public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();resolver.setContentNegotiationManager((ContentNegotiationManager)beanFactory.getBean(ContentNegotiationManager.class));resolver.setOrder(-2147483648);return resolver;
}

        当我们做文件上传的时候我们也会发现multipartResolver自动被配置好的页面

<form action="/upload" method="post" enctype="multipart/form-data"><input name="pic" type="file"><input type="submit">
</form>

        Controller

@ResponseBody
@RequestMapping("/upload")
public String upload(@RequestParam("pic")MultipartFile file, HttpServletRequest request){String contentType = file.getContentType();String fileName = file.getOriginalFilename();/*System.out.println("fileName-->" + fileName);System.out.println("getContentType-->" + contentType);*///String filePath = request.getSession().getServletContext().getRealPath("imgupload/");String filePath = "D:/imgup/";try {this.uploadFile(file.getBytes(), filePath, fileName);} catch (Exception e) {// TODO: handle exception}return "success";
}public static void uploadFile(byte[] file, String filePath, String fileName) throws Exception {File targetFile = new File(filePath);if(!targetFile.exists()){targetFile.mkdirs();}FileOutputStream out = new FileOutputStream(filePath+fileName);out.write(file);out.flush();out.close();
}

文件上传大小可以通过配置来修改

打开application.properties, 默认限制是10MB,我们可以任意修改

1.4.1.4静态资源访问

        参见4.2

1.4.1.5消息转换和格式化

        Springboot自动配置了消息转换器

        格式化转换器的自动注册

        时间类型我们可以在这里修改

        在配置文件中指定好时间的模式我们就可以输入了

1.4.1.6欢迎页面的自动配置

        Springboot自动指定resources下的index.html

1.4.2Springboot扩展springmvc 

        在实际开发中springboot并非完全自动化,很多跟业务相关我们需要自己扩展,springboot给我提供了接口。

        我们可以来通过实现WebMvcConfigurer接口来扩展

public interface WebMvcConfigurer {default void configurePathMatch(PathMatchConfigurer configurer) {}default void configureContentNegotiation(ContentNegotiationConfigurer configurer) {}default void configureAsyncSupport(AsyncSupportConfigurer configurer) {}default void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {}default void addFormatters(FormatterRegistry registry) {}default void addInterceptors(InterceptorRegistry registry) {}default void addResourceHandlers(ResourceHandlerRegistry registry) {}default void addCorsMappings(CorsRegistry registry) {}default void addViewControllers(ViewControllerRegistry registry) {}default void configureViewResolvers(ViewResolverRegistry registry) {}default void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {}default void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> handlers) {}default void configureMessageConverters(List<HttpMessageConverter<?>> converters) {}default void extendMessageConverters(List<HttpMessageConverter<?>> converters) {}default void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> resolvers) {}default void extendHandlerExceptionResolvers(List<HandlerExceptionResolver> resolvers) {}@Nullabledefault Validator getValidator() {return null;}@Nullabledefault MessageCodesResolver getMessageCodesResolver() {return null;}
}
1.4.2.1在容器中注册视图控制器(请求转发)

        创建一个MyMVCCofnig实现WebMvcConfigurer接口,实现一下addViewControllers方法我们完成通过/tx访问,转发到success.html工作

@Configuration
public class MyMVCCofnig implements WebMvcConfigurer{@Overridepublic void addViewControllers(ViewControllerRegistry registry) {registry.addViewController("/tx").setViewName("success");}
}
1.4.2.2注册格式化器

        用来可以对请求过来的日期格式化的字符串来做定制化。当然通过application.properties配置也可以办到。

@Override
public void addFormatters(FormatterRegistry registry) {registry.addFormatter(new Formatter<Date>() {@Overridepublic String print(Date date, Locale locale) {return null;}@Overridepublic Date parse(String s, Locale locale) throws ParseException {return new SimpleDateFormat("yyyy-MM-dd").parse(s);}});
}
1.4.2.3消息转换器扩展fastjson

        在pom.xml中引入fastjson

<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.47</version>
</dependency>

        配置消息转换器,添加fastjson

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {FastJsonHttpMessageConverter fc = new FastJsonHttpMessageConverter();FastJsonConfig fastJsonConfig = new FastJsonConfig();fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);fc.setFastJsonConfig(fastJsonConfig);converters.add(fc);
}

        在实体类上可以继续控制

public class User
{private  String username;private  String password;private int age;private int score;private int gender;@JSONField(format = "yyyy-MM-dd")private Date date;}
1.4.2.4拦截器注册

1.创建拦截器

public class MyInterceptor implements HandlerInterceptor {@Overridepublic boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {System.out.println("前置拦截");return true;}@Overridepublic void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {System.out.println("后置拦截");}@Overridepublic void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {System.out.println("最终拦截");}
}

拦截器注册

@Override
public void addInterceptors(InterceptorRegistry registry) {registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/hello2");
}

1.5配置嵌入式服务器

1.5.1如何定制和修改Servlet容器的相关配置;

修改和server有关的配置(ServerProperties);

server.port=8081
server.context‐path=/tx
server.tomcat.uri‐encoding=UTF‐8

1.5.2注册Servlet三大组件【Servlet、Filter、Listener】

        由于SpringBoot默认是以jar包的方式启动嵌入式的Servlet容器来启动SpringBootweb应用,没有web.xml文件。

        1.servlet

//注册三大组件
@Bean
public ServletRegistrationBean myServlet(){ServletRegistrationBean registrationBean = new ServletRegistrationBean(newMyServlet(),"/myServlet");return registrationBean;
}

        2. FilterRegistrationBean

@Bean
public FilterRegistrationBean myFilter(){FilterRegistrationBean registrationBean = new FilterRegistrationBean();registrationBean.setFilter(new MyFilter());registrationBean.setUrlPatterns(Arrays.asList("/hello","/myServlet"));return registrationBean;
}

        3. ServletListenerRegistrationBean

@Bean
public ServletListenerRegistrationBean myListener(){ServletListenerRegistrationBean<MyListener> registrationBean = newServletListenerRegistrationBean<>(new MyListener());return registrationBean;
}

SpringBoot帮我们自动SpringMVC的时候,自动的注册SpringMVC的前端控制器;DispatcherServlet
DispatcherServletAutoConfiguration中:

@Bean(name = DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME)
@ConditionalOnBean(value = DispatcherServlet.class, name =
DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public ServletRegistrationBean dispatcherServletRegistration(DispatcherServlet dispatcherServlet) {ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet, this.serverProperties.getServletMapping());//默认拦截: / 所有请求;包静态资源,但是不拦截jsp请求; /*会拦截jsp//可以通过server.servletPath来修改SpringMVC前端控制器默认拦截的请求路径registration.setName(DEFAULT_DISPATCHER_SERVLET_BEAN_NAME);registration.setLoadOnStartup(this.webMvcProperties.getServlet().getLoadOnStartup());if (this.multipartConfig != null) {registration.setMultipartConfig(this.multipartConfig);}return registration;
}

1.6使用外置的Servlet容器

嵌入式Servlet容器:应用打成可执行的jar

优点:简单、便携;

缺点:默认不支持JSP、优化定制比较复杂.;

        外置的Servlet容器:外面安装Tomcat---应用war包的方式打包;

步骤

1)、必须创建一个war项目;(利用idea创建好目录结构)

2)、将嵌入式的Tomcat指定为provided 

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring‐boot‐starter‐tomcat</artifactId><scope>provided</scope>
</dependency>

3)配置项目的目录结构

 

4)部署Tomcat

3)、必须编写一个SpringBootServletInitializer的子类,并调用configure方法

public class ServletInitializer extends SpringBootServletInitializer {@Overrideprotected SpringApplicationBuilder configure(SpringApplicationBuilder application) {//传入SpringBoot应用的主程序return application.sources(SpringBoot04WebJspApplication.class);}
}

4)、启动服务器就可以使用;

原理

jar包:执行SpringBoot主类的main方法,启动ioc容器,创建嵌入式的Servlet容器;

war包:启动服务器,服务器启动SpringBoot应用【SpringBootServletInitializer】,启动ioc容器;

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

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

相关文章

如何接入DeepSeek布局企业AI系统开发技术

在当今科技飞速发展的时代&#xff0c;人工智能&#xff08;AI&#xff09;已成为企业提升竞争力、实现创新突破的关键驱动力。DeepSeek作为一款强大的AI工具&#xff0c;为企业开发自身AI系统提供了有力支持。那么&#xff0c;企业该如何接入DeepSeek进行AI系统开发呢&#xf…

日期累加(注意点)

注意点&#xff1a;①月可能超过12月 ②新年需要重新判断闰年 日期累加 #include <stdio.h>int pd(int year) {return (year % 4 0 && year % 100 ! 0) || (year % 400 0); }int main() {int m;int year, month, day, add;scanf("%d", &m);f…

vue3 前端路由权限控制与字典数据缓存实践(附Demo)

目录 前言1. 基本知识2. Demo3. 实战 前言 &#x1f91f; 找工作&#xff0c;来万码优才&#xff1a;&#x1f449; #小程序://万码优才/r6rqmzDaXpYkJZF 从实战中出发&#xff1a; 1. 基本知识 Vue3 和 Java 通信时如何进行字典数据管理 需要了解字典数据的结构。通常&#…

用于 RGB-D 显著目标检测的点感知交互和 CNN 诱导的细化网络

摘要 通过整合来自RGB图像和深度图的互补信息&#xff0c;能够提升在复杂且具有挑战性场景下的显著性目标检测&#xff08;SOD&#xff09;能力。近年来&#xff0c;卷积神经网络&#xff08;CNNs&#xff09;在特征提取和跨模态交互方面的重要作用已得到充分挖掘&#xff0c;但…

基于SpringBoot的“校园周边美食探索及分享平台”的设计与实现(源码+数据库+文档+PPT)

基于SpringBoot的“校园周边美食探索及分享平台”的设计与实现&#xff08;源码数据库文档PPT) 开发语言&#xff1a;Java 数据库&#xff1a;MySQL 技术&#xff1a;SpringBoot 工具&#xff1a;IDEA/Ecilpse、Navicat、Maven 系统展示 校园周边美食探索及分享平台结构图…

chrome浏览器插件拓展捕获页面的响应体内容

因为chrome extension官方没有的直接获取响应体的方法&#xff0c;所以需要自己实现方法来获取&#xff0c;实现的方式有很多种&#xff0c;这是记录的第二种&#xff0c;第一种就是使用vconsole来实现&#xff0c;vconsole是一个开源框架&#xff0c;一个轻量、可拓展、针对手…

【Linux指北】Linux的重定向与管道

一、了解Linux目录配置标准FHS FHS本质&#xff1a;是一套规定Linux目录结构&#xff0c;软件建议安装位置的标准。 (使用Linux来开发产品或者发布软件的公司、个人太多&#xff0c;如果每家公司或者个人都按照自己的意愿来配置文件或者软件的存放位置&#xff0c;这无疑是一…

Qt6.8.2中JavaScript调用WebAssembly的js文件<1>

前段时间已经学习了如何在QtAssembly中编译FFmpeg资源了&#xff0c;接下来需要使用Html来调用QtCreator中WebAssembly套件写的功能&#xff0c;逐步实现javascrpt与c复杂功能的视线。 接下来我先为大家介绍一个非常简单的加法调用吧&#xff01; 功能讲解 开发环境&#xf…

3.13-进程

进程 进程和程序 程序&#xff1a;编译好的二进制文件&#xff0c;不占用系统资源&#xff08;内存&#xff09;。进程&#xff1a;活跃的程序&#xff0c;不消耗系统图资源&#xff08;内存&#xff09;。 MMU PCB 进程控制块 本质&#xff1a;结构体&#xff1a;struct …

在 CentOS 7 上安装 PHP 7.3

在 CentOS 7 上安装 PHP 7.3 可以按照以下步骤进行操作&#xff1a; 1. 安装必要的依赖和 EPEL 仓库 EPEL&#xff08;Extra Packages for Enterprise Linux&#xff09;是为企业级 Linux 提供额外软件包的仓库&#xff0c;yum-utils 用于管理 yum 仓库。 sudo yum install -…

DeepSeek模型本地化部署方案及Python实现

DeepSeek实在是太火了&#xff0c;虽然经过扩容和调整&#xff0c;但反应依旧不稳定&#xff0c;甚至小圆圈转半天最后却提示“服务器繁忙&#xff0c;请稍后再试。” 故此&#xff0c;本文通过讲解在本地部署 DeepSeek并配合python代码实现&#xff0c;让你零成本搭建自己的AI…

C++从入门到入土(七)——多态

目录 前言 多态的概念 多态的定义 虚函数的介绍 虚函数的重写/覆盖 析构函数的重写 override和final关键字 纯虚函数和抽象类 重写/重载/隐藏总结 多态的原理 小结 前言 C一共有三个特性&#xff0c;封装、继承和多态&#xff0c;在前面的文章中&#xff0c;我们分别…

浅谈时钟启动和Systemlnit函数

时钟是STM32的关键&#xff0c;是整个系统的心脏&#xff0c;时钟如何启动&#xff0c;时钟源如何选择&#xff0c;各个参数如何设置&#xff0c;我们从源码来简单分析一下时钟的启动函数Systemlnit&#xff08;&#xff09;。 Systemlnit函数简介 我们先来看一下源程序的注释…

【数据结构】6栈

0 章节 3&#xff0e;1到3&#xff0e;3小节。 认知与理解栈结构&#xff1b; 列举栈的操作特点。 理解并列举栈的应用案例。 重点 栈的特点与实现&#xff1b; 难点 栈的灵活实现与应用 作业或思考题 完成学习测试&#xff12;&#xff0c;&#xff1f; 内容达成以下标准(考核…

HOT100——链表篇Leetcode160. 相交链表

文章目录 题目&#xff1a;Leetcode160. 相交链表原题链接思路代码 题目&#xff1a;Leetcode160. 相交链表 给你两个单链表的头节点 headA 和 headB &#xff0c;请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点&#xff0c;返回 null 。 图示两个链表…

江科大51单片机笔记【16】AD/DA转换(下)

写在前言 此为博主自学江科大51单片机&#xff08;B站&#xff09;的笔记&#xff0c;方便后续重温知识 在后面的章节中&#xff0c;为了防止篇幅过长和易于查找&#xff0c;我把一个小节分成两部分来发&#xff0c;上章节主要是关于本节课的硬件介绍、电路图、原理图等理论知识…

【CF】Day5——Codeforces Round 921 (Div. 2) BC

B. A Balanced Problemset? 题目&#xff1a; 思路&#xff1a; 这道题要我们分成n个子问题&#xff0c;我们假设这几个子问题分别是a1,a2,a3,...an&#xff0c; 那么就是让我们求 gcd(a1,a2,a3,....,an)&#xff0c;我们假设这个值是d 那么就有 d | a1&#xff0c;d | a2…

Mininet 自定义拓扑类型详解

Mininet 通过 --topo 参数支持多种自定义网络拓扑结构&#xff0c;适用于不同场景的网络模拟需求。以下是所有内置拓扑类型及其参数说明&#xff1a; 一、基础拓扑类型 拓扑类型参数格式说明示例命令singlesingle,<n>单一交换机连接所有主机&#xff08;默认 2 台主机&a…

图论part3|101.孤岛的总面积、沉没孤岛、417. 太平洋大西洋水流问题

101. 孤岛的总面积 &#x1f517;&#xff1a;101. 孤岛的总面积思路&#xff1a;和昨天的岛的区别是&#xff1a;是否有挨着边的岛屿 所以可以先遍历四条边挨着的岛屿&#xff0c;把他们标记为非孤岛再计算其他岛屿当中的最大面积 代码&#xff1a;&#xff08;深度搜索&…

第十一届蓝桥杯单片机国赛

什么&#xff1f;4T模拟赛和省赛做起来轻轻松松&#xff1f;不妨来挑战一下第十一届国赛&#xff0c;这一届的国赛居然没考超声波、串口通信&#xff01;只要你正确地理解了题目的意思&#xff0c;规避出题人挖的坑&#xff0c;拿个国一轻轻松松。 附件&#xff1a;第十一届蓝桥…