본문 바로가기
프로그래밍/Spring boot

Spring boot + JSP

by oedpus 2019. 9. 20.

1. build.gradle dependency 추가

compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
compile 'javax.servlet:jstl:1.2'

 

2. JSP 디렉토리 추가 및 테스트 JSP 파일 생성

  src/main/webapp/WEB-INF/jsp/ 경로에 해당하는 폴더 생성

  hello.jsp 파일 생성.

  내용은 간단히 본문에 Hello world!!

 

3. application.yml 수정. JSP 경로 지정

spring:
  mvc:
    view:
      prefix: /WEB-INF/jsp/
      suffix: .jsp

 

4. TestController 생성

@Controller
public class TestController {

	@GetMapping("/hello")
	public String test() {
		return "hello";
	}
}

 

5. 브라우져에 localhost:8080/hello 입력 후 확인

'프로그래밍 > Spring boot' 카테고리의 다른 글

Mybatis Enum 사용  (0) 2019.11.15
Spring boot 에러 페이지 설정  (0) 2019.09.06
Spring boot + Mybatis  (0) 2019.09.04

댓글