반응형
    
    
    
  
package hello.hellospring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
    @GetMapping("/")
    public String home(){
        return "home";
    }
}
▶ localhost:8080으로 접속시 home.html이 보이는 Controller 작성

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Home</title>
</head>
<body>
    <div class="container">
        <div>
            <h1>Hello Spring</h1>
            <p>회원 기능</p>
            <p>
                <a href="/members/new">회원 가입</a>
                <a href="/members">회원 목록</a>
            </p>
        </div>
    </div>
</body>
</html>
▶ 회원 가입을 클릭시 /members/new로 이동
▶ 회원 목록을 클릭시 /members로 이동

▶ localhost:8080을 접속했을 때의 모습

▶ 회원 가입 클릭시의 모습 → localhost:8080/members/new로 접속
▶ 아직 html 파일을 생성하지 않아 Whitelabel Error Page가 뜸

▶ 회원 목록 클릭시의 모습 → localhost:8080/members로 접속
▶ 아직 html 파일을 생성하지 않아 Whitelabel Error Page가 뜸
반응형
    
    
    
  'Spring > inflearn' 카테고리의 다른 글
| 회원 웹 기능 - 조회 (0) | 2022.09.01 | 
|---|---|
| 회원 웹 기능 - 등록 (0) | 2022.08.31 | 
| 자바 코드로 직접 스프링 빈 등록하기 (0) | 2022.08.29 | 
| 컴포넌트 스캔과 자동 의존관계 설정 (0) | 2022.08.28 | 
| 회원 서비스 테스트 (0) | 2022.08.25 |