nhnacademy-aiot1-5 / study

공부한 내용을 기록하는 저장소입니다.
MIT License
0 stars 0 forks source link

프론트서버 - 회원가입 구현 중 th:object 사용 관련 이슈 #34

Open siddltkfkd opened 3 months ago

siddltkfkd commented 3 months ago

방법 1 th:object 사용

<form th:object="${user}" th:action="@{/submitForm}" method="post">
    <div class="mb-3">
        <label for="id" class="form-label">아이디</label>
            <input type="text" class="form-control" id="id" th:field="*{id}" aria-describedby="textHelp">
    </div>
    ...
<form>

장점

방법 2 항상 쓰던 그 방법

<form th:action="@{/submitForm}" method="post">
    <div class="mb-3">
        <label for="id" class="form-label">아이디</label>
            <input type="text" class="form-control" id="id" aria-describedby="textHelp">
    </div>
    ...
<form>

장점

siddltkfkd commented 3 months ago

방법 1이 좋으면 축하 이모티콘, 방법 2가 좋으면 하트 이모티콘 달아주세요

jeongyongs commented 3 months ago

프론트는 받은 데이터를 백엔드 서버로 그대로 넘겨줘도 될 것 같아요.

siddltkfkd commented 3 months ago

스프링 프레임워크 기초를 까먹다니.. 삽질했네요

@ModelAttribute는 생략 가능 html input 태그에 name 속성을 지정해주면 modelAttribute에 자동으로 매핑됨 -> 그래서 늘 쓰던 그 방법으로 가기로 했습니다~