Spring/SpringBoot
View Resolver 설정 하는 법
hyeonseong
2022. 8. 24. 15:19
설정 순서
1. properties에 경로 설정
2. 라이브러리 설치(Tomcat Embed Jasper, JSTL)
3. 올바른 경로에 파일 생성
1. application.properties 에 아래 처럼 작성
만약 내가 생성할 파일 확장자가 .html 이라면 .jsp -> html로 바꿔준다.
2. View Resolver 를 위한 라이브러리 2개 설치
Tomcat Embed Jasper 9.0.22 라고 되있지만 추후 .65로 버전변경 했다.
JSTL 라이브러리
gradle 에서 의존성 부분에 붙여넣기
Gradle - Refresh Gradle Project 해준다.
3. 올바른 경로에 파일 생성
위의 fix 경로들과 라이브러리가 합쳐지면
루트 경로가 /demo/src/main/webapp/WEB-INF/views/파일명.jsp 가 된다
/demo/src/main/webapp은 라이브러리가 설정해준 경로이다.
src - main - webapp - WEB-INF - views 아래에 jsp 파일 생성
jsp파일을 띄우기 때문에 @Controller 사용