📝 Spring
🖥️ 1. 기본객체들
-
${#request}
-
${#response}
-
${#session}
-
${#servletContext}
- spring boot 2.x 버전은 모든 객체 지원 가능
-
${#locale}
- spring boot 3.x 버전부터 ${#locale}만 지원 가능
🖥️2. Spring Boot static 폴더와 template 폴더의 차이
2-1. template
2-2. static

🖥️ 3. @PostConstruct
- 객체가 생성된 후 별도의 초기화 작업을 위해 실행하는 메서드를 선언한다.
@PostConstruct 어노테이션을 설정해놓은 init 메서드는 WAS가 띄워질 때 실행된다.
@PostConstruct
public void init() {
System.out.println("초기화 메서드 실행");
itemRepository.save(new Item("testA", 100000, 10));
itemRepository.save(new Item("testB", 200000, 20));
}
🖥️ 4. @PreDestroy
- 스프링 컨테이너에서 객체 (빈)을 제거하기 전에 해야할 작업이 있다면 메서드 위에 사용하는 어노테이션
@PreDestroy
public void destroy() {
System.out.println("종료 메서드 호출");
}
🖥️ 5. redirect 시 사용되는 속성
- RedirectAttribute : 화면에 "저장되었습니다." 메시지 출력