Spring MVC 1편 서블릿 (HTTP 요청 데이터 - GET 쿼리 파라미터)

신재원·2023년 6월 13일

Spring MVC 1편

목록 보기
11/35

📣 메시지 바디 없이, 쿼리 파라미터를 사용

전달 데이터

  • username=hello
  • age=20

쿼리 파라미터는 URL에 ?을 시작으로 데이터를 보낼수있으며, 추가 파라미터는 & (Shift + 7) 로 구분합니다.

  • http://localhost:8080/request-header?username=shin&age=25 URL로 접속합니다.
  • getParameter() 메소드에의해 쿼리 파라미터인, username, age 가 출력됩니다.
  • 대부분 경우에는 단일 파라미터를 조회하지만 복수 파라미터 조회는 알아 보기만 하겠습니다.
    http://localhost:8080/request-header?username=shin&age=25&username=kim URL일 경우, getParameterValues() 메소드를 사용해 출력합니다.

0개의 댓글