springboot(2)內置序列化框架為Jackson及springboot文件目錄結構


Jackson常用注解:

指定字段不返回:@JsonIgnore
指定日期格式:@JsonFormat(pattern="yyyy-MM-dd hh:mm:ss",locale="zh",timezone="GMT+8")
空字段不返回:@JsonInclude(Include.NON_NUll)
指定別名:@JsonProperty

SpringBoot2.x目錄文件結構
簡介:SpringBoot目錄文件結構和官方推薦的目錄規范

1、目錄講解
src/main/java:存放代碼
src/main/resources
static: 存放靜態文件,比如 css、js、image, (訪問方式 http://localhost:8080/js/main.js)
templates:存放靜態頁面jsp,html,tpl
config:存放配置文件,application.properties
resources:

2、引入依賴 Thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
注意:如果不引人這個依賴包,html文件應該放在默認加載文件夾里面,
比如resources、static、public這個幾個文件夾,才可以訪問

3、同個文件的加載順序,靜態資源文件
Spring Boot 默認會挨個從
META/resources > resources > static > public 里面找是否存在相應的資源,如果有則直接返回。

4、默認配置
1)官網地址:https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-static-content

2)spring.resources.static-locations = classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/

5、靜態資源文件存儲在CDN

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM