09 2022 档案
摘要:<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <g
阅读全文
摘要:页面提交的请求数据(get,post)都可以和对象属性进行绑定 @PostMapping("/saveUser") public Person saveUser(Person person){ return person; }
阅读全文
摘要:Map<String,Object> map、Model model、HttpServletRequest request都是可以给request域中放数据,再用request.getAttribute取数据 package com.java.boot.controller; import org.
阅读全文
摘要:路径变量@PathVariable ①获取指定路径变量: @GetMapping("/car/{id}/owner/{userName}") public Map<String,Object> getCar(@PathVariable("id") int id, @PathVariable("use
阅读全文
摘要:欢迎页 将index.html放入默认的静态资源路径下,会默认访问。 访问路径:http://localhost:8080/ 如下设置了项目的根访问路径,则欢迎页访问需使用:http://localhost:8080/my/ spring:# mvc:# static-path-pattern: /
阅读全文
摘要:默认静态资源目录 类路径下:/static、/public、/resources、/META-INF/resources 以下路径下静态资源可直接访问,如http://localhost:8080/hu4.jpeg 原理:静态映射/** 请求进来,先看controller能不能处理,不能处理的所有请
阅读全文
摘要:package com.java.boot.config; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.boot.c
阅读全文
摘要:import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component//组件加入容器中 @Conf
阅读全文
摘要:条件装配:满足Conditional指定的条件,则进行组件注入 @Configuration//告诉springboot这是一个配置类 public class MyConfig { @Bean("tom") public Stu stu01(){ return new Stu("汤姆"); } @
阅读全文
摘要:import boot.bean.Stu; import boot.bean.User; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configu
阅读全文
摘要:①创建maven工程 ②pom.xml中添加父工程,集成springboot父项目 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <ve
阅读全文
摘要:父工程pom.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001
阅读全文
摘要:1.官网下载maven安装包 https://maven.apache.org/download.cgi https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip 2.配置仓库 apache-ma
阅读全文
摘要:创建的方式 ①通过集合 ②通过数组 ③通过Stream的of() Stream 自己不会存储元素 Stream 不会改变源对象,会返回一个持有结果的新Stream Stream 操作时延迟执行的,等到需要结果的时候才执行 一个中间操作链,对数据源的数据进行处理,一旦执行终止操作,就执行中间操作链,并
阅读全文
摘要:使用情景 当要传递给lambda体的操作,已经有实现的方法了,可以使用方法引用。 方法引用也是函数式接口的实例 使用格式 (类(对象):: 方法名) ①对象 :: 非静态方法 ②类 :: 静态方法 ③类 :: 非静态方法 使用要求 要求接口中的抽象方法的形参列表和返回值类型与方法引用的方法的形参列表
阅读全文
摘要:1.Lambda表达式的本质:作为函数式接口的实例 2.格式: ->:Lambda操作符 或 箭头操作符 ->左边:Lambda形参列表(接口中抽象方法的形参列表) ->右边:Lambda体(重写的抽象方法的方法体) 3.Lambda表达式的使用: ->左边:Lambda形参列表的参数类型可以省略:
阅读全文
摘要:反射的概念 public class Person { private String name; public int age; public Person(String name, int age) { this.name = name; this.age = age; } private Per
阅读全文
摘要:public class TCPTest { @Test public void client() { Socket socket = null; OutputStream os = null; try { //1.创建Socket对象,指明服务器端的ip和端口号 InetAddress inet
阅读全文
摘要:导入第三方jar:commons-io @Test public void test7() throws IOException { File srcFile = new File("hello.txt"); File destFile = new File("hello2.txt"); //Fil
阅读全文
摘要:/* 序列化过程:将内存中的java对象保存到磁盘中或通过网络传输出去,使用ObjectOutputStream */ @Test public void test5() throws IOException { FileOutputStream fos = new FileOutputStream
阅读全文
摘要:@Test public void test4() throws IOException { InputStreamReader isr = null; try { FileInputStream fis = new FileInputStream("D:\\java.txt"); isr = ne
阅读全文
摘要:@Test public void test3(){ BufferedInputStream bis = null; BufferedOutputStream bos = null; try { //节点流 FileInputStream fis = new FileInputStream("D:\
阅读全文