[study]이론정리/Spring Boot32 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. Spring MVC - 쿠키값 얻기 6> 쿠기값 얻기 - 쿠키 생성을 먼저후 쿠키값을 얻어야 한다. # 쿠키 생성 // 쿠기 생성(맵핑) @GetMapping("/set-cookie") public String set_cookie(HttpServletRequest request, HttpServletResponse response) { Cookie c = new Cookie("userid", "hello1234"); response.addCookie(c); return "hello"; } # 전체 쿠키 얻기 // 쿠키 얻기(맵핑) 1- 전체쿠키얻기 @GetMapping("/get-cookie1") public String get_cookie1(HttpServletRequest request) { Cookie [] cookie.. 2024. 7. 2. Spring MVC - 요청헤더값 얻기 5> 요청헤더값 얻기 ==> 헤더의 name 값은 기본적으로 대소문자 구별안함. # 모든 요청헤더값 얻기 // 요청헤더값 전부 얻기 @GetMapping("/header1") public String header1(HttpServletRequest request) { Enumeration names = request.getHeaderNames(); while(names.hasMoreElements()) { String name = names.nextElement(); String value = request.getHeader(name); logger.info("logger: header .. 2024. 7. 2. 이전 1 2 3 4 5 6 ··· 8 다음