Java Spring boot JSP 연동
application.properties
server.port = 8081
spring.datasource.driver=com.mysql.cj.jdbc.Driver
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/myDBName?&serverTimezone=UTC&autoReconnect=true&allowMultiQueries=true&characterEncoding=UTF-8
spring.datasource.username=myid
spring.datasource.password=****
spring.datasource.mapper-locations=classpath:/mapper*.xml
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
build.gradle
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
implementation 'javax.servlet:jstl'
Controller 생성
package com.myweb.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HelloController {
@RequestMapping("/")
public String hello() {
return "main";
}
}
jsp 파일 생성
src/main/webapp/WEB-INF/views/main.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
Main Page
</body>
</html>
서버 실행 포트(8081)
