学习主题:SpringBoot

  1. SpringBoot介绍
  2. 什么是Spring Boot?

Spring Boot 设计目的是用来简化新Spring 应用的初始搭建以及开发过程。他拥有嵌入的Tomcat,无需部署WAR 文件 , Spring Boot 并不是对Spring 功能上的增强,而是提供了一种快速使用Spring 的方式。可以通过SpringBoot官网 快速构建SpringBoot项目, 自动为你生成启动类以及相关文件等

  1. Spring Boot有哪些特点?

嵌入的Tomcat,无需部署WAR 文件

提供一种快速使用Spring 的方式

  1. 构建SpringBoot项目以及启动器讲解
  2. Spring Boot常见的启动器有哪些?




springboot Filter不起作用_springboot filter


  1. Spring Boot的Web启动器的坐标是什么?

<!-- springBoot的启动器 -->
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
1. 编写HelloWorld
2. 如何编写Spring Boot启动类?
@SpringBootApplication
public class Client {
 public static void main(String[] args) {
 SpringApplication.run(Client.class, args);
 }
}
1. 编写Spring Boot启动类时需要注意什么?
 @SpringBootApplication 表示当前项目是一个SpringBoot项目
1. Spring Boot整合Servlet
2. Spring Boot整合Servlet有几种方式?
 方式一
常规方式 ,通过注解注入Servlet的name与访问路径 ,然后启动器如以往一样
方式二
servlet代码如同javaEE时一样 ,但是启动器创建了一个获取Servlet注册的Bean的方法 ,通过@bean 标签,相当于在配置文件中配置了servlet的访问路径
1. 各种方式有什么特点?
 方式一,使用注解@WebServlet创建.方式二,通过@Bean注入
1. Spring Boot整合Filter
2. Spring Boot整合Filter有几种方式?
方式一:@WebFilter(filterName=“FirstFilter”,urlPatterns="/first") ,表示在web.xml注册Filter ,过滤器名字为FirstFilter ,拦截的url是 /first
方式二:通过@Bean注册filter
1. 各种方式有什么特点?
 方式一,使用注解@WebFilter创建.方式二,通过@Bean注入
1. springBoot整合Listener
2. Spring Boot整合Listener有几种方式?
方式一:@WebListener 自动注册,相当于在web.xml中添加如下代码
方式二:在启动器类中通过@Bean注入
1. 各种方式有什么特点?
 方式一,使用注解@ WebListener创建.方式二,通过@Bean注入
1. Spring Boot访问静态资源
2. 在Spring Boot中访问静态资源有几种方式?
方式一: 从classpath/static 的目录访问静态资源
方式二: webapp 根目录下
1. Spring Boot文件上传
2. 在Spring Boot中如何设置单个上传文件大小?
 /**
 * 处理文件上传___上传到本地
 */
 @RequestMapping("/fileUpLoad")
 public Map<String, Object> fileUpload(MultipartFile file) throws Exception {
 System.out.println(file.getOriginalFilename());
 //放在e盘下
 file.transferTo(new File("e:/" + file.getOriginalFilename()));
 Map<String, Object> map = new HashMap<>();
 map.put("msg", "ok");
 return map;
 }
1. 在Spring Boot中如何设置一次请求上传文件大小?
配置文件中添加
spring.http.multipart.maxFileSize
1. Spring Boot整合jsp
2. 在Spring Boot中整合jsp需要添加哪些坐标?
 <dependencies>
 <!-- springBoot 的启动器 -->
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-web</artifactId>
 </dependency>
 <!-- jstl -->
 <dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>jstl</artifactId>
 </dependency>
 <!-- jasper:SpringBoot对jsp的支持 -->
 <dependency>
 <groupId>org.apache.tomcat.embed</groupId>
 <artifactId>tomcat-embed-jasper</artifactId>
 <scope>provided</scope>
 </dependency>
 </dependencies>
1. Spring Boot整合Freemarker
2. 在Spring Boot中整合Freemarker需要添加哪些坐标?
 <!-- springBoot 的启动器 -->
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-freemarker</artifactId>
 </dependency>
 </dependencies>
1. Freemarker视图的扩建名是什么?
 .ftl
1. Thymeleaf入门-创建项目
2. 在Spring Boot中整合Thymeleaf需要添加哪些坐标?
 <!-- springBoot 的启动器 -->
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-thymeleaf</artifactId>
 </dependency>
  1. Thymeleaf视图的扩建名是什么?

.html

  1. Thymeleaf视图要求放到项目的哪个目录下?

Java/Resource/templates

  1. Thymeleaf入门-Thymeleaf基本使用
  2. Thymeleaf的特点是什么?

1,调用内置对象一定要用#

2,大部分的内置对象都以s 结尾strings、numbers、dates

  1. 在使用Thymeleaf时页面会出现什么异常?

 在使用springboot的过程中,如果使用thymeleaf作为模板文件, 则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错! 即声明thymeleaf使用非严格的html。启动之后访问页面会报如下错误

  1. 解决Thymeleaf中标签匹配的异常有几种方式?

方法一、升级新版本

方法二、修改模式为LEGACYHTML5