2021. 1. 7. 09:29
1. @RequestParam("파라미터") String id
public String example (@RequestParam("id") String id)
요청 : url?id=홍길동
System.out.println(id); //홍길동
2. @RequestBody HashMap<String, String> map 으로받는 방법
public String example(@RequestBody HashMap<String, String> map)
요청 : url?id=홍길동&age=1&today=20210107
for(Entry<String, String> entry : map.entrySet())
{
System.out.println(String.format("key: %s, val: %s", entry.getKey(), entry.getValue()));
}
key: id val: 홍길동
key: age val: 1
key: today val: 20210107
'Spring Framework > Spring' 카테고리의 다른 글
[Intellij] 2. Spring MVC 프로젝트 설정 (0) | 2021.02.17 |
---|---|
[Spring] json 형식 주고 받기 (0) | 2021.01.09 |
[spring] 2. 한글 처리 filter (web.xml) (0) | 2020.06.09 |
[Spring] 의존 주입 - 작성중 (0) | 2020.04.21 |
[Spring] 클래스 컨테이너 (0) | 2020.04.20 |