Spring/Spring boot

[15] Spring Web MVC : Index page and Favicon

낙타선생 2020. 6. 24. 21:09
반응형

[Index page]

index page는 application root에 접근했을 때 보여주는 page로 index page를 찾는 순서는 다음과 같습니다.

  1. index.html (static resource)를 찾아보고 있으면 제공
  2. index.{template file 확장자} (dynamic resource)를 찾아보고 있으면 제공
  3. 두 종료의 resource에 해당하는 index page가 없는 경우 spring boot error page 제공

/resources/static/index.html file을 생성하고 그 내용을 다음과 같이 작성해봅니다.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Index page</title>
</head>
<body>
<h1>Welcom to spring boot world</h1>
</body>
</html>

 

application을 기동하고 http://localhost:8080/ 로 접근하면 white label error page 대신 다음과 같이 index page가 조회됨을 확인할 수 있습니다.

 

 

 


[Favicon]

favicon은 browser의 page tab에 보여지는 작은 icon입니다.

static resource path에 favicon.ico file을 추가해서 변경할 수 있습니다. (favicon은 https://favicon.io/ 에서 쉽게 제작할 수 있습니다.)

제작한 favicon을 drag하여 static resource path에 넣어줍니다.

 

favicon은 추가하거나 변경해도 즉각적으로 적용되지 않는 경우가 많습니다. 이런 경우 다음과 같이 일련의 작업을 진행하여 적용할 수 있습니다.

  1. favicon.ico (또는 favicon file에 준하는 file resource)에 해당하는 page를 직접 reqeust합니다.
  2. page를 새로고침 합니다.
  3. browser를 재시작합니다.