인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

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

ymyj33님의 프로필 이미지
ymyj33

작성한 질문수

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

html 파일로 인식못하는 문제 궁금합니다.

작성

·

823

0

안녕하세요. 선생님

회원등록하는 부분에 members폴더 만들고 하위에 createMemberForm.html을 생성했는데

html파일로 인식을 하지 않습니다.. 어떠한 경우에 이렇게되는건가요? 다른 파일 test.html을 생성해보면 정상적으로 되는데.. 이것만 그렇습니다.. 왜그런지 이유가 궁금합니다.

답변 1

0

Dowon Lee님의 프로필 이미지
Dowon Lee
지식공유자

안녕하세요, 이도원입니다. 

죄송하지만, 질문하신 내용을 다시 확인하고 싶습니다다. 

/resources/templates 폴더에 html 파일을 생성하였는데, test.html 파일은 정상적으로 작동하고, createMemberForm.html 파일은 작동하지 않는다는 것인가요? application.yml 파일이나(또는 application.properties) pom.xml 파일에 관련 설정은 되어 있을까요? 본 과정에서는 RestController만을 사용했는데, 웹 페이지등을 보여주기 위해 Controller를 추가할 때에 대한 설정입니다. test.html 파일은 /resources 폴더 밑에 생성하시면 됩니다. 

<pom.xml>

    <!-- WEB -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

<application.yml>

spring:
thymeleaf:
prefix: classpath:templates/
check-template-location: true
suffix: .html
mode: HTML5
cache: false
template-resolver-order: 0

<test.html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello, World
</body>
</html>

<HelloWorldWebController.java>

@Controller
public class HelloWorldWebController {
@GetMapping("/test")
public String getUser() {
return "test";
}

확인해 보시고, 문의사항 있으시면 다시 연락 주세요. 

감사합니다. 

ymyj33님의 프로필 이미지
ymyj33

작성한 질문수

질문하기