spring boot設定預設訪問路徑

2021-10-03 02:59:37 字數 793 閱讀 2097

一共有兩種方法

1.繼承webmvcconfigureradapter類或實現webmvcconfigurer介面

建立乙個config包,然後在包內建立mymvcconfig類。

import org.springframework.context.annotation.configuration;

import org.springframework.core.ordered;

import org.springframework.web.servlet.config.annotation.viewcontrollerregistry;

import org.springframework.web.servlet.config.annotation.webmvcconfigureradapter;

@configuration

public class mymvcconfig extends webmvcconfigureradapter

}

注意:如果用這個方法html頁面需要在static下,不然會出現404錯誤,找不到頁面。

2.@controller路由設定

在controller層中建立乙個indexcontroller類

import org.springframework.stereotype.controller;

@controller

public class indexcontroller

}

springboot設定預設訪問首頁

springboot中的html靜態資源通常是放在resource下的static資料夾先,放在這個資料夾下的html檔案,可以直接通過埠號後直接加html名稱就可以直接訪問。但是需要我們在輸入埠號或者系統名稱時就可以訪問首頁。解決辦法如下 package com.example.demo.conf...

struts2預設action設定了卻訪問不到

1 錯誤原因 我的package中共有兩個action,第乙個是預設action,用於訪問的action不存在時候的出錯處理,第二個是萬用字元方式寫的action,name採用 形式的全萬用字元。配置好了,訪問預設action時候會報錯,但如果第二個action的class屬性的包名中也包含萬用字元...

SpringBoot 預設日誌

by default,if you use the starters logback is used for logging.spring.io原話 log level error,warn,info,debug,or trace.等級順序公升高 作用 如設定info 則顯示error,warn,i...