@RequestParam(value = "name", required = false) String name, Model model
@RequestParam이 적용된 필드가 없으면 Bad Request, Required String parameter 'name' is not present 라는 예외를 발생시킨다.
기본 요청 : http://localhost:8080/hello-mvc?name=이름
required = false는 http://localhost:8080/hello-mvc 여기까지만 넣어도 가능하게 해준다.
(default가 true이니까 원래는 뒤에 파라미터를 넣지 않으면 오류)
'프로그래밍 > Spring' 카테고리의 다른 글
어노테이션(@RequestMapping, @RequestParam) (0) | 2024.12.17 |
---|