본문 바로가기

분류 전체보기245

Spring MVC - HandlerInterceptor (X 라고 가정) 13> HandlerInterceptor (X 라고 가정) - 기본적인 Spring MVC 아키텍쳐에서 3군데 위치에서 가로채기 가능   Controller 요청전/요청후 와 jsp 응답전에서 HandlerInterceptor(가로채기) 사용가능. - Spring MVC 아키텍쳐   웹브라우저 -------필터-------> DispatcherServlet---(X)---->Controller------->Service------->Repository                                      |                                                                           |                             .. 2024. 7. 3.
Spring MVC - FileUpload & download 12> 파일 업로드 (1) 개요 - 서블릿/JSP 및 Spring Framework 에서는 의존성 설정이 필요함. - SpringBoot 는 의존성 필요없음. (-starter-web 에 자동으로 포함되어 있음) (2) 파일 업로드 화면        File to upload:      Notes about the file:            to upload the file!      반드시 method 와 enctype 를 다음값으로 설정해야된다.   - method="POST"   - enctype="multipart/form-data"   멀티 업로드 가능.       (3) UploadDTO 작성   public class UploadDTO {     String theText;     Mul.. 2024. 7. 2.
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.