강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

Tkhp Sch님의 프로필 이미지
Tkhp Sch

작성한 질문수

v1/index.html이란 파일이 어디에 있나요? 화면UI에 관한 파일을 어디서 제공받았나요?

작성

·

81

0

http://localhost:5000/v1/index.html

위처럼 입력하려면 v1이라는 폴더에 index.html이라는 파일이 있어야 하지 않나요?

그게 제 파일에는 없는데, 어떻게 해야하나요?

아까주신 답변을 읽어보았습니다.

UI 화면 관련

스프링 부트 서버에 미리 만들어진 UI 화면을 추가할 때, 일반적으로 정적 리소스(HTML, CSS, JS 등)를 src/main/resources/static 폴더에 넣으면 됩니다. 브라우저에서 http://localhost:5000/index.html 같이 접근할 수 있습니다.

static이란 폴더도 없고, 제공받은 HTML, CSS, JS등의 파일도 없습니다. 어디에 그 파일이 있나요?

질문이 자꾸 지워져요!

e26.jpg

답변 1

0

안녕하세요, 인프런 AI 인턴입니다.

Tkhp Sch님,

스프링 부트 프로젝트에서 정적 리소스(HTML, CSS, JS 등)을 제공하기 위해서는 해당 파일들을 적절한 디렉토리에 배치해야 합니다. 일반적으로 아래와 같은 디렉토리 구조를 사용합니다.

정적 리소스를 위한 디렉토리 구조

src/main/resources/static

현재 사용자님의 프로젝트에서 src/main/resources/static 폴더가 없다면 수동으로 만들어 주셔야 합니다. v1이라는 폴더를 추가하고 그 안에 index.html 파일을 넣으려면 다음과 같은 단계를 따를 수 있습니다:

  1. src/main/resources/static 디렉토리를 생성합니다.
  2. static 폴더 내에 v1 폴더를 생성합니다.
  3. v1 폴더 내에 index.html 파일을 생성합니다.

예제 디렉토리 구조

src
└── main
    └── resources
        └── static
            └── v1
                └── index.html

위와 같은 구조를 사용하면 브라우저에서 http://localhost:5000/v1/index.html로 접근하여 파일을 확인할 수 있습니다.

추가로 static 폴더 내에 필요로 하는 HTML, CSS, JS 파일들을 위치시켜 UI 화면을 제공할 수 있습니다.

이미지 설명에 대한 정보는 아래에서 확인할 수 있습니다:
This image shows a computer screen with a code editor open. The code editor appears to be IntelliJ IDEA or a similar Integrated Development Environment (IDE). The project is named “library-app,” and the structure of the project is visible on the left side, showing various directories and files. - The project contains directories like `build`, `gradle`, `src`, `test`, and several files like `.gitignore` and `build.gradle`.
- Within the `src` folder, under `main/java/com/group/library_app/controller/calculator`, there is a file named `CalculatorController`.
- On the right side of the screen, there is a part of a Java file open, specifically `CalculatorController.java`, showing some Java code. The code snippet includes import statements and parts of a class definition for `CalculatorController`, with annotations like `@RestController`, `@GetMapping`, and `@PostMapping`.The bottom of the screen has different tabs and tools typically available in an IDE, such as running and debugging options, and there is a console output showing a log of operations or errors.

추가적으로 궁금한 점이 있으시면 언제든지 질문해 주세요.

감사합니다.

Spring Boot Reference Documentation - Static Content

Tkhp Sch님의 프로필 이미지
Tkhp Sch

작성한 질문수

질문하기