一、springBoot对日志的支持
1.springboot默认选用slf4j,logback
2.springBoot默认已经配置好了日志
3.通过LoggerFactory.getLogger(xx.class); 获得日志对象
4.常用方法trace debugger info warn error,通过日志对象调。
5.日志级别:TRACE, DEBUG, INFO(默认级别), WARN, ERROR, FATAL, OFF,logging.level.主配置包路径=日志级别
logging.file=文件名-->将文件日志存储于文件中,日志默认放在项目根路径下
6.指定日志显示格式
a.日志显示在控制台中
logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n
%d : 日期时间 后面 大括号为格式
% thread 当前线程
%-5level 显示日志级别,-5表示从左显示5个字符宽度
%logger{50} 设置日志长度
%msg 日志消息
%n 回车
b.日志显示在文件中
logging.pattern.file=%d{yyyy-MM-dd} ** [%thread] ** %-5level ** %logger{50} ** %msg%n
二、springBoot对静态资源的支持 WebMvc --约定类WebMvcAutoConfiguration.java
1.springBoot将静态资源以Jar文件形式引入,https://www.webjars.org/
2.默认欢迎页:index.html
3.默认页面标签logo:favicon.ico
4.自定义静态资源目录:spring.resources.static-locations=classpath:/static1/,classpath:/res/
自定义目录后,约定的目录失效
5.动态资源,使用模板引擎,推荐 thymeleaf
三、Thymeleaf简单使用
1.<html xmlns:th="http://www.thymeleaf.org">
2.th:text 获取文本值 (不转义)
th:utext 获取文本值(转义)
四、支持JSP
1、使用外部的Tomcat,Pom文件中注意
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope><!-- 默认,作用为打包的时候内置Tomcat不打包 -->
</dependency>
2、创建对应的目录结构,webapps/WEB-INF