컨트롤러의 변수를 뷰에서 쓰기

김태림·2021년 6월 10일
0

spring

목록 보기
3/4

ex..

@GetMapping("/joinIdDupChk")
	public String joinIdDupChk(String id, Model model) {
		int rowCount = memberService.getCountById(id);
		
		boolean isIdDup = (rowCount == 1) ? true : false;
		
		// model 객체에 View(JSP)에서 사용할 데이터를 저장하기
		// 스프링이 request.setAttribute(키, 값); 호출로 옮겨줌model.addAttribute("isIdDup",isIdDup);
		model.addAttribute("id",id);
		
		return "member/joinIdDupChk";
	}

모델 인터페이스를 임포트해서 모델 객체에 넣어주면 자동으로 request에 스프링이 넣어준다

0개의 댓글