프로젝트

[ bible cash] thymLeaf 초기 화면 코드

do_it_zero 2025. 1. 13. 17:57
@Controller
public class SignupController {
    @GetMapping("/signup")
    public String getSignupPage(){
        return "signup";
    }

    @PostMapping("/signup")
    public String signup(@ModelAttribute SignUpForm signUpForm, Model model){
        model.addAttribute("id",signUpForm.getId());
        return "home";

    }
}

 

@Data
public class SignUpForm {
    private String group;
    private String id;

}

 

index

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>로그인 페이지</title>

    <!-- 부트스트랩 CSS CDN -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

    <!-- 부트스트랩 아이콘 (선택 사항) -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
</head>
<body class="d-flex justify-content-center align-items-center" style="height: 100vh; background-color: #f4f6f9;">

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6 col-lg-4">
            <!-- 중앙 박스 -->
            <div class="card shadow">
                <div class="card-body p-4">
                    <!-- 제목 -->
                    <h3 class="text-center mb-4">2교구 7팀</h3>

                    <!-- 아이디 입력란 -->
                    <div class="form-group">
                        <label for="userId">아이디</label>
                        <input type="text" id="userId" class="form-control" placeholder="아이디를 입력하세요">
                    </div>

                    <!-- 로그인 버튼 -->
                    <button class="btn btn-primary btn-block">로그인</button>

                    <div class="d-flex justify-content-between mt-3">
                        <!-- 회원가입 버튼 -->
                        <a href="/signup" class="btn-secondary btn-block text-center">회원가입</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 부트스트랩 JS 및 Popper.js CDN -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

 

home

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>회원가입 결과</title>
    <!-- 부트스트랩 CSS CDN -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
    <h2 class="text-center">회원가입 결과</h2>
    <p>입력한 아이디는: <strong th:text="${id}"></strong></p> <!-- id 값 출력 -->

    <div class="text-center">
        <a href="/signup" class="btn btn-secondary">다시 회원가입</a>
    </div>
</div>

<!-- 부트스트랩 JS 및 Popper.js CDN -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.2/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

 

signup

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>회원가입</title>

    <!-- 부트스트랩 CSS CDN -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container mt-5">
    <h2 class="text-center">여정 합류</h2>

    <!-- 회원가입 폼 -->
    <form action="/signup" method="POST">
        <div class="form-group">
            <label for="group">아이디 그룹</label>
            <!-- 드롭다운 선택 -->
            <select id="group" name="group" class="form-control">
                <option value="A">A</option>
                <option value="B">B</option>
                <option value="C">C</option>
            </select>
        </div>

        <div class="form-group">
            <label for="id">아이디</label>
            <input type="text" id="id" class="form-control" name="id" placeholder="아이디를 입력하세요">
        </div>

        <button type="submit" class="btn btn-primary btn-block">회원가입</button>
    </form>
</div>
</body>
</html>