본문 바로가기

개발환경/Spring Boot

Spring Boot jsp view 사용 방법

Maven:

pom.xml 설정

<!-- 아래 내용 추가 -->
<dependency>   
	<groupId>org.apache.tomcat.embed</groupId> 
    <artifactId>tomcat-embed-jasper</artifactId> 
</dependency>

 

Gradle:

build.gradle

implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
implementation group: 'javax.servlet', name: 'jstl', version: '1.2'

 

application.properties 설정

spring.mvc.view.prefix=/WEB-INF/views/  - JSP파일이 위치할 경로설정
spring.mvc.view.suffix=.jsp

 

패키지 구조 변경

src -> main -> webapp 추가

1. webapp -> WEB-INF, resources 생성

2. WEB-INF -> view(뷰단 폴더 생성)

 

최종 구조

src -> main ->

java

resource

webapp