hanker
@ModelAttribute 어노테이션 본문
@ModelAttribute 어노테이션
여러가지 코드를 보면 컨트롤러에서 파라미터를 받는 부분에 @ModelAttribute 어노테이션이 붙어 있는걸 볼 수 있다.
이 어노테이션을 사용하면 VO, DTO 클래스에 정의된 값을 파라미터로 받을 수 있는데, 이는 view page에서 폼데이터를 가져올 때 많이 사용한다.
또한 생략도 가능하다.
@RequestMapping(value = "/actionLogin.do")
public String actionLogin(@ModelAttribute("loginVO") LoginVO loginVO, HttpServletRequest request, ModelMap model) throws Exception {
}
@RequestMapping(value = "/actionLogin.do")
public String actionLogin(LoginVO loginVO, HttpServletRequest request, ModelMap model) throws Exception {
}
위 코드와 아래코드의 받아오는 값은 같다.
'SPRING' 카테고리의 다른 글
javax.persistence.TransactionRequiredException: Executing an update/delete query (0) | 2024.09.04 |
---|---|
[Intellij] Entity Class 생성 (1) | 2024.09.03 |
Spring - WebMvcConfigurerAdapter' is deprecated (0) | 2021.11.10 |
Java - 웹 크롤링 이미지 파일 다운로드(Web Crawling img Download) - jsoup (2) (0) | 2021.11.09 |
Java - 웹 크롤링(Web Crawling) - jsoup (1) (0) | 2021.11.09 |