개발환경
/src/main/webapp/WEB-INF/web.xml 파일
<web-app version="3.1" xmlns="http://JAVA.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee; http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd">
<!-- UTF-8 관련 파라미터 설정 -->
<filter>
<filter-name>encodingFilterUTF8</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilterUTF8</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- beans 관련 설정 -->
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.liveBeansView.mbeanDomain</param-name>
<param-value>dev</param-value>
</context-param>
/pom.xml
<properties>
<java-version>1.8</java-version>
<org.springframework-version>4.2.2.RELEASE</org.springframework-version>
<org.aspectj-version>1.2.1</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
...
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
...
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
...
</plugin>
자바 서블릿 관련 의존성 다시 설정
servlet 관련 dependency를 찾음
maven repository 사이트에서 다음을 찾아 알맞는 버전으로 수정
- spring-context-support
- javax.servlet-api
- javax.servlet.jsp-api
- jstl-api
- taglibs-standard-impl
1. javax.servlet-api
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
```
추가로 필요한 라이브러리를 추가한다
예시
- MyBatis
- MySQL
- lombok
- ...
1. MyBatis
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${org.mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${org.mybatis.spring.version}</version>
</dependency>
->mybatis 버전이 없어서 오류가 남, properties부분에 코드 추가
<org.mybatis.version>3.3.0</org.mybatis.version>
<org.mybatis.spring.version>1.2.1</org.mybatis.spring.version>
2.MySQL
<dependency>
<groupId> org.springframework</groupId>
<artifactId> spring-jdbc</artifactId>
<version> ${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId> mysql</groupId>
<artifactId> mysql-connector-java </artifactId>
<version> 5.1.27</version>
</dependency>
<dependency>
<groupId> org.mariadb.jdbc</groupId>
<artifactId> mariadb-java-client </artifactId>
<version> 1.7.4</version>
</dependency>
상단 메뉴 window - preferences - web - jsp file - editor - templates - New JSP File(html 5) 선택, edit
아래 코드 붙여넣기 후 apply
<%@ page language="java" contentType="text/html; charset=${encoding}"
pageEncoding="${encoding}"%>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="${encoding}">
<title>JSP Title</title>
</head>
<body>
${cursor}
</body>
</html>
/src/main/webapp/WEB-INF/views/home.jsp 파일도 수정
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
<html>
<head>
<title>Home</title>
<meta charset="utf-8" />
</head>
<body>
<h1>
Hello world!
</h1>
<P> The time on the server is ${serverTime}. </P>
</body>
</html>