- GET
"/sign-up"
μμ²μ λ°μμ account/sign-up.htmlμ 보μ¬μ€λ€. - νμκ°μ
νΌμμ μ
λ ₯λ°μ μ μλ μ 보λ₯Ό
λλ€μ
,μ΄λ©μΌ
,ν¨μ€μλ νΌ
κ°μ²΄λ‘ μ 곡νλ€.
@Controller
public class AccountController {
@GetMapping("/sign-up")
public String signUpForm(Model model) {
return "account/sign-up";
}
}
-
μλ² ν νλ¦Ώ μμ§(Thymeleaf...)μμ μ¬μ©ν μ μλ κ°μ²΄λ₯Ό μ μ₯ν μ μλ€.
-
model.addAttribute(key, value)
key - value μμ ν΅ν΄μ viewμ μ λ¬ν λ°μ΄ν° κ°μ²΄λ₯Ό μ§μ νλ€.
@Controller
μ΄λ Έν μ΄μ μ λͺ μνλ©΄, Spring MVC Containerκ° Clientμ μμ²μΌλ‘λΆν° Viewλ₯Ό λ°ννλ€. ν΄λΉ ν΄λμ€κ° 컨νΈλ‘€λ¬μμ μ€νλ§ μ»¨ν μ΄λμκ² μλ €μ€λ€.
- GET λ°©μμΌλ‘ urlμΌλ‘ λ€μ΄μ¨ μμ²μ μ²λ¦¬νλ λ©μλλ₯Ό λ§€ννλ€.
-
<html xmlns:th="http://www.thymeleaf.org">
λ₯Ό μ μΌλ©΄ ν΄λΉ html νμΌμ΄ νμ리νμμ λͺ μνλ€. -
url μμ² λ³΄λΌ λ :
@{/url}
ex)
th:href="@{/}"
,th:actoin="@{/sign-up}"
-
th:field="*{valueName}"
-
th:object="${objectName}"