SpringBoot-09-首頁和錯誤頁定製
1、首頁定製
-
在WebMvcAutoConfiguration.class中找到以下程式碼,得出
自定義一個index.html,放在靜態資源目錄下,就可以實現首頁定製
@Bean
public WelcomePageHandlerMapping welcomePageHandlerMapping(ApplicationContext applicationContext, FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider) {
WelcomePageHandlerMapping welcomePageHandlerMapping = new WelcomePageHandlerMapping(new TemplateAvailabilityProviders(applicationContext), applicationContext, this.getWelcomePage(), this.mvcProperties.getStaticPathPattern());
welcomePageHandlerMapping.setCorsConfigurations(this.getCorsConfigurations());
return welcomePageHandlerMapping;
}
//從靜態資源目錄裡獲取 index.html 當作首頁
private Optional<Resource> getWelcomePage() {
return Arrays.stream(locations).map(this::getIndexHtml).filter(this::isReadable).findFirst();
}
private Resource getIndexHtml(String location) {
return this.resourceLoader.getResource(location + "index.html");
2、錯誤頁定製
-
在 resources 資料夾下建立 error 資料夾
-
新建 404.html ,則出現 404 錯誤就會自動跳轉到這個頁面
-
新建 500.html ,則出現 500 錯誤就會自動跳轉到這個頁面
-
相關推薦
SpringBoot-09-首頁和錯誤頁定製
1、首頁定製 在WebMvcAutoConfiguration.class中找到以下程式碼,得出 自定義一個index.html,放在靜態資源目錄下,就可以實現首頁定製
springboot-首頁和網站圖示定製
1 搭建一個springboot專案 參考地址:springboot-hello world 2 執行專案,訪問首頁 首頁和網站圖示都是spring預設的
springboot-springsecurity:記住我和登入頁定製
承接:springboot-springsecuroty:登出和許可權控制 1 記住我實現 1.1 在SecurityConfig中新增http.rememberMe();這行程式碼
如何在Google Chrome瀏覽器中更改/設定首頁和起始頁?
When the Google Chrome browser is started or a new tab is opened a default page is provided to the user. This default page is called a Homepage or Start page. They are not the same where the
首頁和次頁地址不一致,爬取網站通訊錄
from pyquery import PyQuery as pq import requests import csv def get_env(url=\"http://localhost:8080/index.htm\", data=\"\", headers=\"\"):
(收藏)網站首頁和欄目頁等 index.html 301跳轉 不帶 index.html 主域
技術標籤:論跑路的藝術伺服器iiswindows serverurl 其實參考大部分網站都沒有做所謂的 index.html 301跳轉主域,大部分都是隱藏主域後面的index.html,其實參考搜尋引擎影響感覺差不多。
Flutter https://flutter.cn/docs學習之向 Android 應用中新增閃屏頁和啟動頁
https://flutter.cn/docs/development/ui/splash-screen/android-splash-screen 宣告一個啟動主題Define a launch theme
Uni-App 啟動頁和引導頁介紹
Uni-App 啟動頁和引導頁介紹 Uni-App 啟動頁和引導頁是兩個不同的東西,啟動頁是 Uni-App 自帶的,不可去掉,只能修改相關配置。而引導頁完全是需要開發者自行開發的。
dedecms呼叫【同級或下級】欄目的方法,channelartlist在列表頁和內容頁呼叫【同級或下級】欄目文章
使用織夢dedecms時,想在列表頁和內容頁呼叫同級欄目的文章,當然可以使用 {dede:channelartlist typeid=‘1’ row=\'5\'}
springboot:springboot的web開發(靜態資源的處理方式、首頁和圖示定製、thymeleaf模板引擎初識)
1、靜態資源的處理方式 (1)依賴的方式 匯入依賴: <dependency> <groupId>org.webjars</groupId>
SpringBoot首頁和圖示處理
技術標籤:G_網際網路分散式技術# G1_SpringBootjavaspring boot 首頁處理 靜態資原始檔夾說完後,我們繼續向下看原始碼!可以看到一個歡迎頁的對映,就是我們的首頁!
SpringBoot⑥Web開發:靜態資源、首頁和圖示
7、Web開發:靜態資源 在專案中需要使用到大量的 JS、CSS 等靜態資源,如何匯入靜態資源呢?
JAVA錯誤類結果類和分頁結果類程式碼詳解
這篇文章主要介紹了JAVA錯誤類結果類和分頁結果類程式碼詳解,文中通過示例程式碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
SpringBoot+MySQL+Jpa實現對資料庫的增刪改查和分頁詳解
一、 使用Springboot+Jpa實現對mysql資料庫的增刪改查和分頁功能 JPA是Java Persistence API的簡稱,中文名Java持久層API,是JDK 5.0註解或XML描述物件-關係表的對映關係,並將執行期的實體物件持久化到資料庫中。
SpringBoot專案新增新聞首頁與詳情頁
1、在New、Tag和Type的Repository介面中新增相應的資料庫查詢語句與對應方法頭 NewRepository中新增:
SpringBoot預設首頁跳轉設定
大家在使用SpringBoot時候會遇到將系統介面入門設定為\"/\",那麼這個就是我們常見的預設首頁跳轉的設定。解決的方式有兩種
python測試開發django(20)--admin首頁和title修改
前言 django的admin首頁預設顯示的\"Django管理\",title顯示的是\"Django站點管理員\",這裡的文案內容可以修改成自己專案的後臺頁面內容
SpringBoot - 自定義錯誤頁1(基礎:配置404等錯誤的靜態頁面、動態模版頁面)
在之前的文章中我介紹瞭如何使用@ControllerAdvice來進行全域性異常處理,但是這種異常處理方式一般用來處理應用級別的異常,一些容器級別的錯誤就處理不了,比如Filter中丟擲的異常。因此,Spring Boot中對於異常的
springboot+mybatis+pagehelper實現分頁和程式碼示例demo
1.pom中引入依賴 <!--mybatis依賴--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.3<
iOS UIScrollView基本使用和按頁滾動
要讓一組檢視View一起滾動,就需要滾動檢視。在Android上提供了ScrollView,而iOS則提供了UIScrollView。UIScrollView比Android上的ScrollView多出3種特性: