diff --git a/frontproject/build/classes/frontproject/controller/FrontController.class b/frontproject/build/classes/frontproject/controller/FrontController.class new file mode 100644 index 0000000..9cbcc4c Binary files /dev/null and b/frontproject/build/classes/frontproject/controller/FrontController.class differ diff --git a/frontproject/build/classes/frontproject/controller/SampleTBController.class b/frontproject/build/classes/frontproject/controller/SampleTBController.class new file mode 100644 index 0000000..1754492 Binary files /dev/null and b/frontproject/build/classes/frontproject/controller/SampleTBController.class differ diff --git a/frontproject/build/classes/frontproject/dao/SampleTBDAO.class b/frontproject/build/classes/frontproject/dao/SampleTBDAO.class new file mode 100644 index 0000000..2a89801 Binary files /dev/null and b/frontproject/build/classes/frontproject/dao/SampleTBDAO.class differ diff --git a/frontproject/build/classes/frontproject/vo/SampleTBVO.class b/frontproject/build/classes/frontproject/vo/SampleTBVO.class new file mode 100644 index 0000000..8387742 Binary files /dev/null and b/frontproject/build/classes/frontproject/vo/SampleTBVO.class differ diff --git a/frontproject/build/classes/listener/FrontListener.class b/frontproject/build/classes/listener/FrontListener.class new file mode 100644 index 0000000..d2fce05 Binary files /dev/null and b/frontproject/build/classes/listener/FrontListener.class differ diff --git a/frontproject/pom.xml b/frontproject/pom.xml new file mode 100644 index 0000000..c0d1673 --- /dev/null +++ b/frontproject/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + frontproject + frontproject + 0.0.1-SNAPSHOT + + + + + jstl + jstl + 1.2 + + + + + + + + maven-compiler-plugin + 3.8.1 + + 17 + + + + + \ No newline at end of file diff --git a/frontproject/src/main/java/frontproject/controller/FrontController.java b/frontproject/src/main/java/frontproject/controller/FrontController.java new file mode 100644 index 0000000..1e3ed5f --- /dev/null +++ b/frontproject/src/main/java/frontproject/controller/FrontController.java @@ -0,0 +1,56 @@ +package frontproject.controller; + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import frontproject.dao.SampleTBDAO; +import frontproject.vo.SampleTBVO; + +/* + frontcontroller는 모든 가상경로를 제일 먼저 받아 역할에 맞는 컨트롤러로 요청을 분기하는 처리를 한다. +*/ + +public class FrontController extends HttpServlet { + + public FrontController() { + super(); + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String requestURL = request.getRequestURI(); // 전체 url(도메인제외) + String contextPath = request.getContextPath(); // 프로젝트 path + + String command = requestURL.substring(contextPath.length() + 1); // 프로젝트 path를 제외한 uri /까지 잘라내 + String[] uris = command.split("/"); + if (uris[0].equals("sampleTB")) { + + SampleTBController sampleTBController = new SampleTBController(); + + sampleTBController.getAction(request, response, uris); + + } + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String requestURL = request.getRequestURI(); // 전체 url(도메인제외) + String contextPath = request.getContextPath(); // 프로젝트 path + + String command = requestURL.substring(contextPath.length() + 1); // 프로젝트 path를 제외한 uri /까지 잘라내 + String[] uris = command.split("/"); + if (uris[0].equals("sampleTB")) { + + SampleTBController sampleTBController = new SampleTBController(); + + sampleTBController.postAction(request, response, uris); + + } + } +} diff --git a/frontproject/src/main/java/frontproject/controller/SampleTBController.java b/frontproject/src/main/java/frontproject/controller/SampleTBController.java new file mode 100644 index 0000000..96d5285 --- /dev/null +++ b/frontproject/src/main/java/frontproject/controller/SampleTBController.java @@ -0,0 +1,142 @@ +package frontproject.controller; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.swing.text.View; + +import frontproject.dao.SampleTBDAO; +import frontproject.vo.SampleTBVO; + +public class SampleTBController { + + public void getAction(HttpServletRequest request, HttpServletResponse response, String[] uris) throws ServletException, IOException { + //frontcontroller에서 sampleTB관련 모든 요청을 받아서 각 목적에 맞는 메서드를 분기하는 영역 + + if(uris[1].equals("list.do")) { + list(request,response); + }else if(uris[1].equals("view.do")){ + view(request,response); + }else if(uris[1].equals("modify.do")){ + modify(request,response); + }else if(uris[1].equals("insert.do")){ + insert(request,response); + } + } + public void postAction(HttpServletRequest request, HttpServletResponse response, String[] uris) throws ServletException, IOException { + //post 요청에 대한 처리 + if(uris[1].equals("modify.do")) { + modifyOk(request,response); + }else if(uris[1].equals("insert.do")) { + insertOk(request,response); + } + } + + private void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + SampleTBDAO sampleTBDao = new SampleTBDAO(); //ctrl shift o + List slist = sampleTBDao.selectList(); + + request.setAttribute("slist", slist); + + RequestDispatcher rd = request.getRequestDispatcher("/sampleTB/list.jsp"); + rd.forward(request, response); + } + + private void view(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String snoParam = request.getParameter("sno"); + int sno = 0; + if(snoParam != null && !snoParam.equals("")) { + sno = Integer.parseInt(snoParam); + }else { + response.sendRedirect("list.do"); + } + + SampleTBDAO sampleTBDao = new SampleTBDAO(); + + SampleTBVO svo = sampleTBDao.selectOne(sno); + + request.setAttribute("svo", svo); + + RequestDispatcher rd = request.getRequestDispatcher("/sampleTB/view.jsp"); + rd.forward(request, response); + } + + private void modify(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + String snoParam = request.getParameter("sno"); + int sno =0; + if(snoParam != null && !snoParam.equals("")) { + sno = Integer.parseInt(snoParam); + }else { + response.sendRedirect("list.do"); + } + + SampleTBDAO sampleTBDao = new SampleTBDAO(); + + SampleTBVO svo = sampleTBDao.selectOne(sno); + + request.setAttribute("svo",svo); + + RequestDispatcher rd = request.getRequestDispatcher("/sampleTB/modify.jsp"); + rd.forward(request, response); + } + + private void modifyOk(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + request.setCharacterEncoding("utf-8"); + String snoParam = request.getParameter("sno"); + int sno =0; + if(snoParam != null && !snoParam.equals("")) { + sno = Integer.parseInt(snoParam); + } + + String title = request.getParameter("title"); + String writer = request.getParameter("writer"); + String body = request.getParameter("body"); + + SampleTBVO svo = new SampleTBVO(); + svo.setSno(sno); + svo.setTitle(title); + svo.setWriter(writer); + svo.setBody(body); + + SampleTBDAO sampleTBDao = new SampleTBDAO(); + int result = sampleTBDao.update(svo); + + if(result>0) { + //수정성공 + response.sendRedirect("view.do?sno="+sno); + }else { + //수정실패 + response.sendRedirect("modify.do?sno="+sno+"&msg=fail"); + } + } + + private void insert(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + RequestDispatcher rd = request.getRequestDispatcher("/sampleTB/insert.jsp"); + rd.forward(request, response); + } + + private void insertOk(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + request.setCharacterEncoding("utf-8"); + SampleTBVO svo = new SampleTBVO(); + svo.setTitle(request.getParameter("title")); + svo.setWriter(request.getParameter("writer")); + svo.setBody(request.getParameter("body")); + + SampleTBDAO sampleTBDao = new SampleTBDAO(); + int result = sampleTBDao.insert(svo); + + response.sendRedirect("list.do"); + + } +} + diff --git a/frontproject/src/main/java/frontproject/dao/SampleTBDAO.java b/frontproject/src/main/java/frontproject/dao/SampleTBDAO.java new file mode 100644 index 0000000..dd5f50f --- /dev/null +++ b/frontproject/src/main/java/frontproject/dao/SampleTBDAO.java @@ -0,0 +1,172 @@ +package frontproject.dao; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +import frontproject.vo.SampleTBVO; + +public class SampleTBDAO { + + private final String url = "jdbc:mysql://localhost:3306/javaspringclass"; + private final String user = "javaspringclass"; + private final String password = "1234"; + + public List selectList(){//ctrl + shift + o + Connection conn = null; + PreparedStatement psmt = null; + ResultSet rs = null; + + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + conn = DriverManager.getConnection(url,user,password); + + String sql = "select * from sampleTB"; + + psmt = conn.prepareStatement(sql); + rs = psmt.executeQuery(); + + List slist = new ArrayList(); + + while(rs.next()) { + SampleTBVO svo = new SampleTBVO(); + svo.setSno(rs.getInt("sno")); + svo.setTitle(rs.getString("title")); + svo.setWriter(rs.getString("writer")); + svo.setRdate(rs.getString("rdate")); + svo.setBody(rs.getString("body")); + + slist.add(svo); + } + + return slist; + + }catch(Exception e) { + e.printStackTrace(); +// return null; 캐치에 걸림 + }finally { + try { //컴파일러 예외처리 때문에 추가로 try-catch 작성 + if(conn != null) conn.close(); + if(psmt != null) psmt.close(); + if(rs != null) rs.close(); + }catch(Exception e) { + e.printStackTrace(); + } + } + + return null; + } + + public SampleTBVO selectOne(int sno) { + Connection conn = null; + PreparedStatement psmt = null; + ResultSet rs = null; + + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + conn = DriverManager.getConnection(url,user,password); + + String sql = "select * from sampleTB where sno=?"; + + psmt = conn.prepareStatement(sql); + psmt.setInt(1,sno); + rs = psmt.executeQuery(); + + SampleTBVO svo = null; + if(rs.next()) { + svo = new SampleTBVO(); + svo.setSno(rs.getInt("sno")); + svo.setTitle(rs.getString("title")); + svo.setWriter(rs.getString("writer")); + svo.setRdate(rs.getString("rdate")); + svo.setBody(rs.getString("body")); + } + return svo; + + }catch(Exception e) { + e.printStackTrace(); + }finally { + try { //컴파일러 예외처리 때문에 추가로 try-catch 작성 + if(rs != null) rs.close(); + if(psmt != null) psmt.close(); + if(conn != null) conn.close(); + }catch(Exception e) { + e.printStackTrace(); + } + } + + return null; + } + + public int update(SampleTBVO svo) { + Connection conn = null; + PreparedStatement psmt = null; + + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + conn = DriverManager.getConnection(url,user,password); + + String sql = " update sampleTB " + + " set title = ? " + + " , writer = ? " + + " , body = ? " + + " where sno = ? "; + psmt = conn.prepareStatement(sql); + psmt.setString(1, svo.getTitle()); + psmt.setString(2, svo.getWriter()); + psmt.setString(3, svo.getBody()); + psmt.setInt(4,svo.getSno()); + + int result =psmt.executeUpdate(); + + return result; + + }catch(Exception e) { + e.printStackTrace(); + }finally { + try { + if(psmt != null) psmt.close(); + if(conn != null) conn.close(); + }catch(Exception e) { + e.printStackTrace(); + } + } + return 0; + } + + + public int insert(SampleTBVO svo) {//메서드를 추가하면 된다. + Connection conn = null; + PreparedStatement psmt = null; + + try { + Class.forName("com.mysql.cj.jdbc.Driver"); + conn = DriverManager.getConnection(url,user,password); + + String sql = "insert into sampleTB(title,body,writer,rdate)values(?,?,?,now())"; + + psmt = conn.prepareStatement(sql); + psmt.setString(1, svo.getTitle()); + psmt.setString(2, svo.getBody()); + psmt.setString(3, svo.getWriter()); + + int result = psmt.executeUpdate(); + + return result; + + }catch(Exception e){ + e.printStackTrace(); + }finally { + try { + if(psmt != null) psmt.close(); + if(conn != null) conn.close(); + }catch(Exception e) { + e.printStackTrace(); + } + } + return 0; + } +} \ No newline at end of file diff --git a/frontproject/src/main/java/frontproject/vo/SampleTBVO.java b/frontproject/src/main/java/frontproject/vo/SampleTBVO.java new file mode 100644 index 0000000..81728dd --- /dev/null +++ b/frontproject/src/main/java/frontproject/vo/SampleTBVO.java @@ -0,0 +1,40 @@ +package frontproject.vo; + +public class SampleTBVO { + private int sno; + private String title; + private String writer; + private String rdate; + private String body; + + public int getSno() { + return sno; + } + public String getTitle() { + return title; + } + public String getWriter() { + return writer; + } + public String getRdate() { + return rdate; + } + public String getBody() { + return body; + } + public void setSno(int sno) { + this.sno = sno; + } + public void setTitle(String title) { + this.title = title; + } + public void setWriter(String writer) { + this.writer = writer; + } + public void setRdate(String rdate) { + this.rdate = rdate; + } + public void setBody(String body) { + this.body = body; + } +} diff --git a/frontproject/src/main/java/listener/FrontListener.java b/frontproject/src/main/java/listener/FrontListener.java new file mode 100644 index 0000000..f524849 --- /dev/null +++ b/frontproject/src/main/java/listener/FrontListener.java @@ -0,0 +1,22 @@ +package listener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +@WebListener +public class FrontListener implements ServletContextListener { + + + public FrontListener() { + } + + public void contextDestroyed(ServletContextEvent sce) { + System.out.println("front 프로젝트 종료"); + } + + public void contextInitialized(ServletContextEvent sce) { + System.out.println("front 프로젝트 실행"); + } + +} diff --git a/frontproject/src/main/webapp/WEB-INF/lib/jstl-1.2.jar b/frontproject/src/main/webapp/WEB-INF/lib/jstl-1.2.jar new file mode 100644 index 0000000..0fd275e Binary files /dev/null and b/frontproject/src/main/webapp/WEB-INF/lib/jstl-1.2.jar differ diff --git a/frontproject/src/main/webapp/WEB-INF/lib/mysql-connector-j-8.4.0.jar b/frontproject/src/main/webapp/WEB-INF/lib/mysql-connector-j-8.4.0.jar new file mode 100644 index 0000000..8294fe0 Binary files /dev/null and b/frontproject/src/main/webapp/WEB-INF/lib/mysql-connector-j-8.4.0.jar differ diff --git a/frontproject/src/main/webapp/WEB-INF/web.xml b/frontproject/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..461b8c9 --- /dev/null +++ b/frontproject/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,28 @@ + + + frontproject + + index.html + index.jsp + index.htm + default.html + default.jsp + default.htm + + + + listener.FrontListener + + + + front + frontproject.controller.FrontController + + + + + front + *.do + + + \ No newline at end of file diff --git a/frontproject/src/main/webapp/index.jsp b/frontproject/src/main/webapp/index.jsp new file mode 100644 index 0000000..f40cdfe --- /dev/null +++ b/frontproject/src/main/webapp/index.jsp @@ -0,0 +1,14 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + +

FrontController를 사용하여 게시판 만들기

+ sampleTB 목록으로 이동 + + + \ No newline at end of file diff --git a/frontproject/src/main/webapp/sampleTB/insert.jsp b/frontproject/src/main/webapp/sampleTB/insert.jsp new file mode 100644 index 0000000..8e491e8 --- /dev/null +++ b/frontproject/src/main/webapp/sampleTB/insert.jsp @@ -0,0 +1,53 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + + +<%-- <% + String msg = request.getParameter("msg"); + if(msg != null && msg.equals("fail")){ + %> + + <% + } +%> --%> + + + + +Insert title here + + +

sampleTB 등록페이지!

+
+ + + + + + + + + + + + + + + +
제목:
작성자:
내용:
+ +
+ + \ No newline at end of file diff --git a/frontproject/src/main/webapp/sampleTB/list.jsp b/frontproject/src/main/webapp/sampleTB/list.jsp new file mode 100644 index 0000000..f67c5a5 --- /dev/null +++ b/frontproject/src/main/webapp/sampleTB/list.jsp @@ -0,0 +1,53 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import = "java.util.*" %> +<%@ page import = "frontproject.vo.SampleTBVO" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%-- <% + List slist = (List)request.getAttribute("slist"); +%> --%> + + + + +Insert title here + + +

sampleTB 목록 페이지

+ + + + + + + + + + + + + + + + + + + <%-- <% + for(int i=0; i + + + + + + + <% + } + %> --%> + +
번호제목작성자작성일
${list.sno}${list.title}${list.writer}${list.rdate}
<%=svo.getSno() %><%=svo.getTitle() %><%=svo.getWriter() %><%=svo.getRdate() %>
+ + + + \ No newline at end of file diff --git a/frontproject/src/main/webapp/sampleTB/modify.jsp b/frontproject/src/main/webapp/sampleTB/modify.jsp new file mode 100644 index 0000000..d596201 --- /dev/null +++ b/frontproject/src/main/webapp/sampleTB/modify.jsp @@ -0,0 +1,74 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="frontproject.vo.SampleTBVO" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + + +<%-- <% + SampleTBVO svo = (SampleTBVO)request.getAttribute("svo"); + + String msg = request.getParameter("msg"); + if(msg != null){ + if(msg.equals("fail")){ + %> + + <%. + } + } +%> --%> + + + + + +Insert title here + + +

sampleTB 수정페이지!

+
+<%-- --%> + + + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + +
글번호:<%=svo.getSno() %>${svo.sno}
제목:
작성자:
작성일:<%=svo.getRdate() %>${svo.rdate}
내용:
+ +
+ + \ No newline at end of file diff --git a/frontproject/src/main/webapp/sampleTB/view.jsp b/frontproject/src/main/webapp/sampleTB/view.jsp new file mode 100644 index 0000000..d586b54 --- /dev/null +++ b/frontproject/src/main/webapp/sampleTB/view.jsp @@ -0,0 +1,50 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ page import="java.util.*" %> +<%@ page import="frontproject.vo.SampleTBVO" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%-- <% + SampleTBVO svo = (SampleTBVO)request.getAttribute("svo"); +%> --%> + + + + +Insert title here + + +

sampleTB 상세페이지

+ + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + + + <%-- --%> + + + +
글번호<%=svo.getSno() %>${svo.sno}
제목<%=svo.getTitle() %>${svo.title}
작성자<%=svo.getWriter() %>${svo.writer}
작성일<%=svo.getRdate() %>${svo.rdate}
내용:<%=svo.getBody() %>${svo.body}
+ <%-- --%> + + + + \ No newline at end of file diff --git a/frontproject/target/classes/META-INF/maven/frontproject/frontproject/pom.xml b/frontproject/target/classes/META-INF/maven/frontproject/frontproject/pom.xml new file mode 100644 index 0000000..c0d1673 --- /dev/null +++ b/frontproject/target/classes/META-INF/maven/frontproject/frontproject/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + frontproject + frontproject + 0.0.1-SNAPSHOT + + + + + jstl + jstl + 1.2 + + + + + + + + maven-compiler-plugin + 3.8.1 + + 17 + + + + + \ No newline at end of file diff --git a/frontproject/target/classes/frontproject/controller/FrontController.class b/frontproject/target/classes/frontproject/controller/FrontController.class new file mode 100644 index 0000000..c0f6d03 Binary files /dev/null and b/frontproject/target/classes/frontproject/controller/FrontController.class differ diff --git a/frontproject/target/classes/frontproject/controller/SampleTBController.class b/frontproject/target/classes/frontproject/controller/SampleTBController.class new file mode 100644 index 0000000..083e9bb Binary files /dev/null and b/frontproject/target/classes/frontproject/controller/SampleTBController.class differ diff --git a/frontproject/target/classes/frontproject/dao/SampleTBDAO.class b/frontproject/target/classes/frontproject/dao/SampleTBDAO.class new file mode 100644 index 0000000..4a3f05f Binary files /dev/null and b/frontproject/target/classes/frontproject/dao/SampleTBDAO.class differ diff --git a/frontproject/target/classes/frontproject/vo/SampleTBVO.class b/frontproject/target/classes/frontproject/vo/SampleTBVO.class new file mode 100644 index 0000000..eb9bec6 Binary files /dev/null and b/frontproject/target/classes/frontproject/vo/SampleTBVO.class differ diff --git a/frontproject/target/classes/listener/FrontListener.class b/frontproject/target/classes/listener/FrontListener.class new file mode 100644 index 0000000..785dc9e Binary files /dev/null and b/frontproject/target/classes/listener/FrontListener.class differ diff --git a/st/Users/MYCOM/Desktop/Workspace/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml b/st/Users/MYCOM/Desktop/Workspace/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml new file mode 100644 index 0000000..5b6c17f --- /dev/null +++ b/st/Users/MYCOM/Desktop/Workspace/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml @@ -0,0 +1,207 @@ + + 4.0.0 + ABC + ABC + 0.0.1-SNAPSHOT + war + + 1.8 + 5.2.3.RELEASE + 1.6.10 + 1.7.30 + 2.14.1 + + + + + org.springframework + spring-context + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + + org.springframework + spring-test + ${org.springframework-version} + test + + + + org.springframework + spring-jdbc + ${org.springframework-version} + + + + + com.mysql + mysql-connector-j + 8.0.33 + + + + org.mybatis + mybatis + 3.4.6 + + + + org.mybatis + mybatis-spring + 1.3.2 + + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.apache.logging.log4j + log4j-api + ${log4j2-version} + + + org.apache.logging.log4j + log4j-core + ${log4j2-version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + 1.2 + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.1 + test + + + org.junit.platform + junit-platform-launcher + 1.7.1 + test + + + org.hamcrest + hamcrest + 2.2 + test + + + org.mockito + mockito-core + 3.9.0 + test + + + org.mockito + mockito-junit-jupiter + 3.9.0 + test + + + + + + maven-eclipse-plugin + 2.9 + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${java-version} + ${java-version} + -Xlint:all + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.test.int1.Main + + + + + diff --git a/st/pom.xml b/st/pom.xml new file mode 100644 index 0000000..5b6c17f --- /dev/null +++ b/st/pom.xml @@ -0,0 +1,207 @@ + + 4.0.0 + ABC + ABC + 0.0.1-SNAPSHOT + war + + 1.8 + 5.2.3.RELEASE + 1.6.10 + 1.7.30 + 2.14.1 + + + + + org.springframework + spring-context + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + + org.springframework + spring-test + ${org.springframework-version} + test + + + + org.springframework + spring-jdbc + ${org.springframework-version} + + + + + com.mysql + mysql-connector-j + 8.0.33 + + + + org.mybatis + mybatis + 3.4.6 + + + + org.mybatis + mybatis-spring + 1.3.2 + + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.apache.logging.log4j + log4j-api + ${log4j2-version} + + + org.apache.logging.log4j + log4j-core + ${log4j2-version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + 1.2 + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.1 + test + + + org.junit.platform + junit-platform-launcher + 1.7.1 + test + + + org.hamcrest + hamcrest + 2.2 + test + + + org.mockito + mockito-core + 3.9.0 + test + + + org.mockito + mockito-junit-jupiter + 3.9.0 + test + + + + + + maven-eclipse-plugin + 2.9 + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${java-version} + ${java-version} + -Xlint:all + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.test.int1.Main + + + + + diff --git a/st/src/main/java/com/a/ezn/BoardController.java b/st/src/main/java/com/a/ezn/BoardController.java new file mode 100644 index 0000000..665c62c --- /dev/null +++ b/st/src/main/java/com/a/ezn/BoardController.java @@ -0,0 +1,98 @@ +package com.a.ezn; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.a.ezn.repo.BoardRepository; + +@Controller +@RequestMapping("/board") +public class BoardController { + + @Autowired + BoardRepository repository; + + /*@Autowired + @Qualifier("board1") + BoardVO board;*/ + /*@Autowired + JdbcTemplate template;*/ + + @RequestMapping(value="/board.do", method=RequestMethod.GET) + public String board(Model model, HttpServletRequest request, BoardVO vo) { + + /*String sql = "select * from sampleTB"; + List slist = template.query(sql, new BeanPropertyRowMapper<>(BoardVO.class));*/ + + List slist = repository.getAllData(); + + model.addAttribute("vo", slist); + + return "board"; + } + + @RequestMapping(value="/post.do", method=RequestMethod.GET) + public String view(@RequestParam(name="sno", defaultValue="0") int sno, Model model) { + + BoardVO vo = repository.selectOne(sno); + model.addAttribute("vo", vo); + + return "view"; + } + + @RequestMapping(value="/write.do", method=RequestMethod.GET) + public String write() { + + return "write"; + } + + @RequestMapping(value="/write.do", method=RequestMethod.POST) + public String writeOk(BoardVO vo) { + + int result = repository.insertOne(vo); + if(result > 0) { + return "redirect:/board/post.do"; + }else { + return "redirect:/board/board.do"; + } + } + + @ResponseBody + @RequestMapping(value="/board.do", method=RequestMethod.POST) + public String postBoard() { + System.out.println("게시글 작성 sql 실행"); + return "a"; + } + + @ResponseBody + @RequestMapping(value="/board.do", method=RequestMethod.PUT) + public String putBoard() { + System.out.println("게시글 수정 sql 실행"); + return "b"; + } + + @ResponseBody + @RequestMapping(value="/board.do", method=RequestMethod.DELETE) + public String deleteBoard() { + System.out.println("게시글 삭제"); + return "c"; + } +} diff --git a/st/src/main/java/com/a/ezn/BoardVO.java b/st/src/main/java/com/a/ezn/BoardVO.java new file mode 100644 index 0000000..d0965f4 --- /dev/null +++ b/st/src/main/java/com/a/ezn/BoardVO.java @@ -0,0 +1,42 @@ +package com.a.ezn; + +public class BoardVO { + private int sno; + private String title; + private String body; + private String writer; + private String rdate; + + public int getSno() { + return sno; + } + public String getTitle() { + return title; + } + public String getBody() { + return body; + } + public String getWriter() { + return writer; + } + public String getRdate() { + return rdate; + } + public void setSno(int sno) { + this.sno = sno; + } + public void setTitle(String title) { + this.title = title; + } + public void setBody(String body) { + this.body = body; + } + public void setWriter(String writer) { + this.writer = writer; + } + public void setRdate(String rdate) { + this.rdate = rdate; + } + + +} diff --git a/st/src/main/java/com/a/ezn/HomeController.java b/st/src/main/java/com/a/ezn/HomeController.java new file mode 100644 index 0000000..c55ce84 --- /dev/null +++ b/st/src/main/java/com/a/ezn/HomeController.java @@ -0,0 +1,44 @@ +package com.a.ezn; + +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +public class HomeController { + +// BoardVO board; + + /*@Autowired + BoardVO board;*/ + /*@Autowired + UserVO vo;*/ + + private static final Logger logger = LoggerFactory.getLogger(HomeController.class); + + @RequestMapping(value = "/", method = RequestMethod.GET) + public String home(Locale locale, Model model) { + logger.info("Welcome home! The client locale is {}.", locale); + + /*board.setTitle("제목"); + System.out.println(board);*/ + + Date date = new Date(); + DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); + + String formattedDate = dateFormat.format(date); + + model.addAttribute("serverTime", formattedDate ); + + return "home"; + } + +} diff --git a/st/src/main/java/com/a/ezn/TestController.java b/st/src/main/java/com/a/ezn/TestController.java new file mode 100644 index 0000000..36200c7 --- /dev/null +++ b/st/src/main/java/com/a/ezn/TestController.java @@ -0,0 +1,14 @@ +package com.a.ezn; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping(value="/test") +public class TestController { + + @RequestMapping(value="home") + public String testHome() { + return "home2"; + } +} diff --git a/st/src/main/java/com/a/ezn/UserVO.java b/st/src/main/java/com/a/ezn/UserVO.java new file mode 100644 index 0000000..2b08c0d --- /dev/null +++ b/st/src/main/java/com/a/ezn/UserVO.java @@ -0,0 +1,22 @@ +package com.a.ezn; + +public class UserVO { + private String id; + private String pw; + + public String getId() { + return id; + } + public String getPw() { + return pw; + } + public void setId(String id) { + this.id = id; + } + public void setPw(String pw) { + this.pw = pw; + } + + + +} diff --git a/st/src/main/java/com/a/ezn/repo/BoardRepository.java b/st/src/main/java/com/a/ezn/repo/BoardRepository.java new file mode 100644 index 0000000..8b5a281 --- /dev/null +++ b/st/src/main/java/com/a/ezn/repo/BoardRepository.java @@ -0,0 +1,35 @@ +package com.a.ezn.repo; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import com.a.ezn.BoardVO; + +@Repository +public class BoardRepository { + + @Autowired + JdbcTemplate template; + + public List getAllData() { + String sql = "select * from sampleTB"; + return template.query(sql, new BeanPropertyRowMapper<>(BoardVO.class)); + } + + public BoardVO selectOne(int sno) { + + String sql = "select*from sampleTB where sno = ?"; + return template.queryForObject(sql, new Object[] {sno}, new BeanPropertyRowMapper<>(BoardVO.class)); + } + + public int insertOne(BoardVO vo) { + String sql = "insert into sampleTB(title, body, writer, rdate)"; + sql+="values(?,?,?, now())"; + int result = template.update(sql, vo.getTitle(), vo.getBody(), vo.getWriter()); + return result; + } +} diff --git a/st/src/main/resources/log4j2.xml b/st/src/main/resources/log4j2.xml new file mode 100644 index 0000000..511eed3 --- /dev/null +++ b/st/src/main/resources/log4j2.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/st/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml b/st/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml new file mode 100644 index 0000000..67b5c05 --- /dev/null +++ b/st/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/st/src/main/webapp/WEB-INF/spring/root-context.xml b/st/src/main/webapp/WEB-INF/spring/root-context.xml new file mode 100644 index 0000000..41509dd --- /dev/null +++ b/st/src/main/webapp/WEB-INF/spring/root-context.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/st/src/main/webapp/WEB-INF/views/board.jsp b/st/src/main/webapp/WEB-INF/views/board.jsp new file mode 100644 index 0000000..974dbf6 --- /dev/null +++ b/st/src/main/webapp/WEB-INF/views/board.jsp @@ -0,0 +1,29 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + +Insert title here + + + + + + + + + + + + + + + + + +
글 번호글 제목글 작성자글 작성일
${bvo.sno}${bvo.title}${bvo.writer}${bvo.rdate}
+ + + \ No newline at end of file diff --git a/st/src/main/webapp/WEB-INF/views/home.jsp b/st/src/main/webapp/WEB-INF/views/home.jsp new file mode 100644 index 0000000..7a2569e --- /dev/null +++ b/st/src/main/webapp/WEB-INF/views/home.jsp @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> + + + Home + + +

+ Hello world! +

+ +

The time on the server is ${serverTime}.

+ + diff --git a/st/src/main/webapp/WEB-INF/views/home2.jsp b/st/src/main/webapp/WEB-INF/views/home2.jsp new file mode 100644 index 0000000..f248680 --- /dev/null +++ b/st/src/main/webapp/WEB-INF/views/home2.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + +Insert title here + + + 여기는 home2 + + \ No newline at end of file diff --git a/st/src/main/webapp/WEB-INF/views/view.jsp b/st/src/main/webapp/WEB-INF/views/view.jsp new file mode 100644 index 0000000..aa70eec --- /dev/null +++ b/st/src/main/webapp/WEB-INF/views/view.jsp @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + +Insert title here + + +

${vo.title}

+
${vo.writer}

+
${vo.body}

+
${vo.rdate}
+ + \ No newline at end of file diff --git a/st/src/main/webapp/WEB-INF/views/write.jsp b/st/src/main/webapp/WEB-INF/views/write.jsp new file mode 100644 index 0000000..b965afd --- /dev/null +++ b/st/src/main/webapp/WEB-INF/views/write.jsp @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + + +Insert title here + + +
+ 제목 :
+ 작성자 :
+ 본문 :
+ +
+ + \ No newline at end of file diff --git a/st/src/main/webapp/WEB-INF/web.xml b/st/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..066df96 --- /dev/null +++ b/st/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,47 @@ + + + + + + contextConfigLocation + /WEB-INF/spring/root-context.xml + + + + + org.springframework.web.context.ContextLoaderListener + + + + encodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + utf-8 + + + + + encodingFilter + / + + + + + appServlet + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + /WEB-INF/spring/appServlet/servlet-context.xml + + 1 + + + + appServlet + / + + + diff --git a/st/src/test/resources/log4j.xml b/st/src/test/resources/log4j.xml new file mode 100644 index 0000000..8715266 --- /dev/null +++ b/st/src/test/resources/log4j.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/st/target/classes/com/a/ezn/BoardController.class b/st/target/classes/com/a/ezn/BoardController.class new file mode 100644 index 0000000..2b8c1e1 Binary files /dev/null and b/st/target/classes/com/a/ezn/BoardController.class differ diff --git a/st/target/classes/com/a/ezn/BoardVO.class b/st/target/classes/com/a/ezn/BoardVO.class new file mode 100644 index 0000000..6dd3fba Binary files /dev/null and b/st/target/classes/com/a/ezn/BoardVO.class differ diff --git a/st/target/classes/com/a/ezn/HomeController.class b/st/target/classes/com/a/ezn/HomeController.class new file mode 100644 index 0000000..1dde3e4 Binary files /dev/null and b/st/target/classes/com/a/ezn/HomeController.class differ diff --git a/st/target/classes/com/a/ezn/TestController.class b/st/target/classes/com/a/ezn/TestController.class new file mode 100644 index 0000000..64ddbe0 Binary files /dev/null and b/st/target/classes/com/a/ezn/TestController.class differ diff --git a/st/target/classes/com/a/ezn/UserVO.class b/st/target/classes/com/a/ezn/UserVO.class new file mode 100644 index 0000000..b0a6d2c Binary files /dev/null and b/st/target/classes/com/a/ezn/UserVO.class differ diff --git a/st/target/classes/com/a/ezn/repo/BoardRepository.class b/st/target/classes/com/a/ezn/repo/BoardRepository.class new file mode 100644 index 0000000..657e1da Binary files /dev/null and b/st/target/classes/com/a/ezn/repo/BoardRepository.class differ diff --git a/st/target/classes/log4j2.xml b/st/target/classes/log4j2.xml new file mode 100644 index 0000000..511eed3 --- /dev/null +++ b/st/target/classes/log4j2.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml b/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml new file mode 100644 index 0000000..5b6c17f --- /dev/null +++ b/st/target/m2e-wtp/web-resources/META-INF/maven/ABC/ABC/pom.xml @@ -0,0 +1,207 @@ + + 4.0.0 + ABC + ABC + 0.0.1-SNAPSHOT + war + + 1.8 + 5.2.3.RELEASE + 1.6.10 + 1.7.30 + 2.14.1 + + + + + org.springframework + spring-context + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${org.springframework-version} + + + commons-logging + commons-logging + + + + + + org.springframework + spring-test + ${org.springframework-version} + test + + + + org.springframework + spring-jdbc + ${org.springframework-version} + + + + + com.mysql + mysql-connector-j + 8.0.33 + + + + org.mybatis + mybatis + 3.4.6 + + + + org.mybatis + mybatis-spring + 1.3.2 + + + + + org.aspectj + aspectjrt + ${org.aspectj-version} + + + + + org.slf4j + slf4j-api + ${org.slf4j-version} + + + org.apache.logging.log4j + log4j-api + ${log4j2-version} + + + org.apache.logging.log4j + log4j-core + ${log4j2-version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2-version} + + + org.slf4j + jcl-over-slf4j + ${org.slf4j-version} + + + + + javax.inject + javax.inject + 1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet.jsp + jsp-api + 2.1 + provided + + + javax.servlet + jstl + 1.2 + + + + + org.junit.jupiter + junit-jupiter-api + 5.7.1 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.7.1 + test + + + org.junit.platform + junit-platform-launcher + 1.7.1 + test + + + org.hamcrest + hamcrest + 2.2 + test + + + org.mockito + mockito-core + 3.9.0 + test + + + org.mockito + mockito-junit-jupiter + 3.9.0 + test + + + + + + maven-eclipse-plugin + 2.9 + + + org.springframework.ide.eclipse.core.springnature + + + org.springframework.ide.eclipse.core.springbuilder + + true + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${java-version} + ${java-version} + -Xlint:all + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + org.test.int1.Main + + + + + diff --git a/st/target/test-classes/log4j.xml b/st/target/test-classes/log4j.xml new file mode 100644 index 0000000..8715266 --- /dev/null +++ b/st/target/test-classes/log4j.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +