클라이언트에서 데이터를 전송했을 때 스프링에서 데이터를 받는 방법 🖥️
2022 / 11 / 7 월
- 스프링에서 데이터를 받는 방법
✔️ 클라이언트에서 데이터를 전송했을 때 스프링에서 데이터를 받는 방법
▶ 필드로 값을 받는다.
1)
클라이언트(HTML)
1. get방식
http://localhost/?age=100&name=홍길동
2. post방식
<form method="post">
<input type="text" name="name">
<input type="text" name="age">
</form>
스프링
- 단순 파라미터 aaa(int age, String name)
2)
클라이언트(HTML)
1. get방식
http://localhost/?age=100&name=홍길동
2. post방식
<form method="post">
<input type="text" name="name">
<input type="text" name="age">
</form>
- 스프링
aaa(SampleDTO dto)
class SampleDTO {
int age;
String name;
}
3)
클라이언트(HTML)
1. get방식
http://localhost/?lst[0].age=100&lst[0].name=홍길동&lst[1].age=100&lst[1].name=홍길동
2. post방식
<form method="post">
<input type="text" name="lst[0].name">
<input type="text" name="lst[0].age">
<input type="text" name="lst[1].name">
<input type="text" name="lst[1].age">
</form>
- 스프링(List컬렉션)
aaa(SampleDTOList dto)
class SampleDTOList {
List<SampleDTO> lst;
}