본문 바로가기

전체 글259

Spring MVC - redirect 와 forward & redirect-flashScope-forward 10> redirect 와 forward (1) 문법:           return "redirect:요청맵핑값"; // 이전 서블릿의 response.sendRedirect("") 동일           return "forward:요청맵핑값"; // 이전 서블릿의 request.getRequestDispatcher("").forward(request, response) 동일 11> redirect-flashScope-forward ==> redirect 했음에도 불구하고 request scope 에 저장된 Model 을 사용할 수 있음.     단, 한번만 가능. ==> RedirectAttributes 모델 + ra.addFlashAttribute("model", "홍길동"); 사용해야한다   /.. 2024. 7. 2.
Spring MVC - Ajax + json 통신 9> Ajax + JSON 통신   Ajax(jQuery)        JSON   웹브라우저 ---------------------------------> Controller ( 전달된 JSON을 DTO에 자동 저장 )                                                @RequestBody                                   값, DTO   전달된 값/DTO   을 JSON 받을수있음.   (@ResponseBody)   * 최종정리   웹브라우저                             서버                     @RequestBody   JSON       ------------------------>  자바    .. 2024. 7. 2.
Spring MVC - Model Scope 8> Model Scope (1) session scope - @SessionAttribute(names={"key값", "key값"})   Model 을 저장할 때 위에서 설정한 key 값을 사용하면   session scope 에 Model 이 저장된다. - 세션을 사용하고자하는 Controller 마다 매번 @SessionAttribute 을   설정해야 된다. package com.exam;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Application { public .. 2024. 7. 2.
Spring MVC - Model 생성 * 아키텍쳐               요청처리(@RequestParam, @RequestHeader, @CookieValue)   웹브라이저 ----------------------> Controller                                         |                                         |             7> Model 생성방법 - 이전 서블릿/jsp 는 scope 에 setAttribute(key,value) 로 저장하고 jsp 에서 보여줌.   scope 종류에 따라서 저장하고      request.setAttribute(key,value);     session.setAttribute(key,value);     applicat.. 2024. 7. 2.