1. 개요

HTML의 Form은 클라이언트가 데이터를 서버로 전송할 때 자주 사용하는 방식이다.

대표적인 사용 예시로는 회원 가입, 상품 주문 등이 있다.

이번 발표에서는 HTML Form을 사용하여 POST 요청으로 데이터를 전송하고, 이를 처리하는 방법을 다룹니다.

2. HTML Form 작성 및 실행

2.1 HTML Form 코드

HTML 파일 생성: src/main/webapp/basic/hello-form.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>POST HTML Form</title>
</head>
<body>
<form action="/request-param" method="post">
  username: <input type="text" name="username" />
  age: <input type="text" name="age" />
  <button type="submit">전송</button>
</form>
</body>
</html>

요점

2.2 실행 흐름

  1. 브라우저에서 실행: http://localhost:8080/basic/hello-form.html
  1. 데이터 입력 후 전송 버튼 클릭

    image.png