# spring boot 에서 jsp를사용하려면, 몇가지 dependency 설정과 경로설정이 필요하다.
# spring starter project 생성 + web 항목 선택
# pom dependency
(생략) <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- for using jsp --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.6.1</version> <scope>provided</scope> </dependency> </dependencies> (생략) |
# application.properties
spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp |
# controller
@Controller public class TestController {
@RequestMapping("/test") public String test(HttpServletRequest request, HttpServletResponse response) {
return "test"; } } |
# project structure
|
# test.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> test page </body> </html> |
'SW개발 > Spring' 카테고리의 다른 글
spring boot과 jsp 기본 프로젝트(웹) (0) | 2017.08.30 |
---|---|
Google App Engine 이클립스 플러그인으로 Spring (Servlet 2.5)프로젝트 연동 (0) | 2017.05.18 |
Google App Engine 에서 Spring Boot 수행 (이클립스) (0) | 2017.05.18 |
Spring Boot jsp 자동 reload 하기 (0) | 2017.05.12 |
Spring Boot 웹기본 참고 (0) | 2017.05.11 |