클라이언트에서 데이타를 전송했을 때 스프링에서 데이터를 받는 방법 : 필드로 값을 받는다.
1)
클라이언트(HTML)
- get방식
http://localhost/?age=100&name=홍길동
- post방식
<form method="post">
<input type="text" name="name">
<input type="text" name="age">
</form>
스프링
- 단순 파라미터 aaa(int age, String name)
2)
클라이언트(HTML)
- get방식
http://localhost/?age=100&name=홍길동
- 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)
- get방식
http://localhost/?lst[0].age=100&lst[0].name=홍길동&lst[1].age=100&lst[1].name=홍길동
- 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;
}
'Spring' 카테고리의 다른 글
@RequestMapping, @Controller,로그 객체 기본사용 (0) | 2022.11.03 |
---|---|
1일차 실습(JSON 내용 포함) (0) | 2022.11.03 |