이안의 평일코딩

2차 프로젝트 본문

Back-end/Team Project

2차 프로젝트

이안92 2020. 10. 16. 15:08
반응형

1. db테이블 생성

 

뉴스
news
n_no NUMBER N-N
n_title VARCHAR2(1000) N-N
n_poster VARCHAR2(1000) N-N
n_regdate VARCHAR2(500) N-N
n_precontent VARCHAR2(2000) N-N
n_content CLOB N-N
n_writer VARCHAR2(500) N-N
n_hit NUMBER N-N
n_tag VARCHAR2(500) NULL
n_cno NUMBER NULL
n_comment CLOB NULL
n_id VARCHAR2(500) NULL
n_pwd VARCHAR2(500) NULL

비디오
video
v_no NUMBER N-N
v_title VARCHAR2(1000) N-N
v_video VARCHAR2(1000) N-N
v_regdate VARCHAR2(500) NULL
v_content CLOB NULL
v_writer VARCHAR2(500) NULL
v_hit NUMBER N-N
v_tag VARCHAR2(500) NULL
v_cno NUMBER NULL
v_comment CLOB NULL
v_id VARCHAR2(500) NULL
v_pwd VARCHAR2(500) NULL

팁
tip
t_no NUMBER N-N
t_title VARCHAR2(1000) N-N
t_poster VARCHAR2(1000) N-N
t_regdate VARCHAR2(500) N-N
t_precontent VARCHAR2(2000) N-N
t_content CLOB N-N
t_writer VARCHAR2(500) N-N
t_hit NUMBER N-N
t_tag VARCHAR2(500) NULL
t_cno NUMBER NULL
t_comment CLOB NULL
t_id VARCHAR2(500) NULL
t_pwd VARCHAR2(500) NULL

스크랩

CREATE TABLE newsscrap(
    no NUMBER PRIMARY KEY,
    id VARCHAR2(20),
    n_no NUMBER,
    t_no NUMBER,
    v_no NUMBER
);

SQL

CREATE TABLE news(
n_no NUMBER NOT NULL,
n_title VARCHAR2(1000) NOT NULL,
n_poster VARCHAR2(1000) NOT NULL,
n_poster2 VARCHAR2(1000),
n_regdate VARCHAR2(500) NOT NULL,
n_precontent VARCHAR2(2000) NOT NULL,
n_content CLOB NOT NULL,
n_writer VARCHAR2(500) NOT NULL,
n_hit NUMBER DEFAULT 0,
n_tag VARCHAR2(500),
n_cno NUMBER,
n_comment CLOB,
n_id VARCHAR2(500),
n_pwd VARCHAR2(500)
);

CREATE TABLE tip(
t_no NUMBER NOT NULL,
t_title VARCHAR2(1000) NOT NULL,
t_poster VARCHAR2(1000) NOT NULL,
t_poster2 VARCHAR2(1000),
t_regdate VARCHAR2(500) NOT NULL,
t_precontent VARCHAR2(2000) NOT NULL,
t_content CLOB NOT NULL,
t_writer VARCHAR2(500) NOT NULL,
t_hit NUMBER DEFAULT 0,
t_tag VARCHAR2(500),
t_cno NUMBER,
t_comment CLOB,
t_id VARCHAR2(500),
t_pwd VARCHAR2(500)
);

CREATE TABLE video(
v_no NUMBER NOT NULL,
v_title VARCHAR2(1000) NOT NULL,
v_poster VARCHAR2(1000) NOT NULL,
v_video VARCHAR2(1000) NOT NULL,
v_regdate VARCHAR2(500),
v_content CLOB,
v_writer VARCHAR2(500),
v_hit NUMBER DEFAULT 0,
v_tag VARCHAR2(500),
v_cno NUMBER,
v_comment CLOB,
v_id VARCHAR2(500),
v_pwd VARCHAR2(500)
);

DROP TABLE news;
DROP TABLE tip;
DROP TABLE video;

DESC news;
DESC tip;
DESC video;
ALTER TABLE news ADD n_like NUMBER DEFAULT 0;
ALTER TABLE tip ADD t_like NUMBER DEFAULT 0;
ALTER TABLE video ADD v_like NUMBER DEFAULT 0;

ALTER TABLE news DROP COLUMN n_like;
ALTER TABLE tip DROP COLUMN t_like;
ALTER TABLE video DROP COLUMN v_like;

 


 

2. VO 생성

com.sist.vo

NewsVO.java

package com.sist.vo;
/*
 * Table NEWS이(가) 생성되었습니다.

이름           널?       유형             
------------ -------- -------------- 
N_NO         NOT NULL NUMBER         
N_TITLE      NOT NULL VARCHAR2(1000) 
N_POSTER     NOT NULL VARCHAR2(1000) 
N_POSTER2             VARCHAR2(1000) 
N_REGDATE    NOT NULL VARCHAR2(500)  
N_PRECONTENT NOT NULL VARCHAR2(2000) 
N_CONTENT    NOT NULL CLOB           
N_WRITER     NOT NULL VARCHAR2(500)  
N_HIT                 NUMBER         
N_TAG                 VARCHAR2(500)  
N_CNO                 NUMBER         
N_COMMENT             CLOB           
N_ID                  VARCHAR2(500)  
N_PWD                 VARCHAR2(500)  

 */
public class NewsVO {
	private int n_no;
	private String n_title;
	private String n_poster;
	private String n_poster2;
	private String n_regdate;
	private String n_precontent;
	private String n_content;
	private String n_writer;
	private int n_hit;
	private String n_tag;
	private int n_cno;
	private String n_comment;
	private String n_id;
	private String n_pwd;
	public int getN_no() {
		return n_no;
	}
	public void setN_no(int n_no) {
		this.n_no = n_no;
	}
	public String getN_title() {
		return n_title;
	}
	public void setN_title(String n_title) {
		this.n_title = n_title;
	}
	public String getN_poster() {
		return n_poster;
	}
	public void setN_poster(String n_poster) {
		this.n_poster = n_poster;
	}
	public String getN_poster2() {
		return n_poster2;
	}
	public void setN_poster2(String n_poster2) {
		this.n_poster2 = n_poster2;
	}
	public String getN_regdate() {
		return n_regdate;
	}
	public void setN_regdate(String n_regdate) {
		this.n_regdate = n_regdate;
	}
	public String getN_precontent() {
		return n_precontent;
	}
	public void setN_precontent(String n_precontent) {
		this.n_precontent = n_precontent;
	}
	public String getN_content() {
		return n_content;
	}
	public void setN_content(String n_content) {
		this.n_content = n_content;
	}
	public String getN_writer() {
		return n_writer;
	}
	public void setN_writer(String n_writer) {
		this.n_writer = n_writer;
	}
	public int getN_hit() {
		return n_hit;
	}
	public void setN_hit(int n_hit) {
		this.n_hit = n_hit;
	}
	public String getN_tag() {
		return n_tag;
	}
	public void setN_tag(String n_tag) {
		this.n_tag = n_tag;
	}
	public int getN_cno() {
		return n_cno;
	}
	public void setN_cno(int n_cno) {
		this.n_cno = n_cno;
	}
	public String getN_comment() {
		return n_comment;
	}
	public void setN_comment(String n_comment) {
		this.n_comment = n_comment;
	}
	public String getN_id() {
		return n_id;
	}
	public void setN_id(String n_id) {
		this.n_id = n_id;
	}
	public String getN_pwd() {
		return n_pwd;
	}
	public void setN_pwd(String n_pwd) {
		this.n_pwd = n_pwd;
	}
}

 

TipVO.java

package com.sist.vo;
/*
 * Table TIP이(가) 생성되었습니다.

이름           널?       유형             
------------ -------- -------------- 
T_NO         NOT NULL NUMBER         
T_TITLE      NOT NULL VARCHAR2(1000) 
T_POSTER     NOT NULL VARCHAR2(1000) 
T_POSTER2             VARCHAR2(1000) 
T_REGDATE    NOT NULL VARCHAR2(500)  
T_PRECONTENT NOT NULL VARCHAR2(2000) 
T_CONTENT    NOT NULL CLOB           
T_WRITER     NOT NULL VARCHAR2(500)  
T_HIT                 NUMBER         
T_TAG                 VARCHAR2(500)  
T_CNO                 NUMBER         
T_COMMENT             CLOB           
T_ID                  VARCHAR2(500)  
T_PWD                 VARCHAR2(500)
 */
public class TipVO {
	private int t_no;
	private String t_title;
	private String t_poster;
	private String t_poster2;
	private String t_regdate;
	private String t_precontent;
	private String t_content;
	private String t_writer;
	private int t_hit;
	private String t_tag;
	private int t_cno;
	private String t_comment;
	private String t_id;
	private String t_pwd;
	public int getT_no() {
		return t_no;
	}
	public void setT_no(int t_no) {
		this.t_no = t_no;
	}
	public String getT_title() {
		return t_title;
	}
	public void setT_title(String t_title) {
		this.t_title = t_title;
	}
	public String getT_poster() {
		return t_poster;
	}
	public void setT_poster(String t_poster) {
		this.t_poster = t_poster;
	}
	public String getT_poster2() {
		return t_poster2;
	}
	public void setT_poster2(String t_poster2) {
		this.t_poster2 = t_poster2;
	}
	public String getT_regdate() {
		return t_regdate;
	}
	public void setT_regdate(String t_regdate) {
		this.t_regdate = t_regdate;
	}
	public String getT_precontent() {
		return t_precontent;
	}
	public void setT_precontent(String t_precontent) {
		this.t_precontent = t_precontent;
	}
	public String getT_content() {
		return t_content;
	}
	public void setT_content(String t_content) {
		this.t_content = t_content;
	}
	public String getT_writer() {
		return t_writer;
	}
	public void setT_writer(String t_writer) {
		this.t_writer = t_writer;
	}
	public int getT_hit() {
		return t_hit;
	}
	public void setT_hit(int t_hit) {
		this.t_hit = t_hit;
	}
	public String getT_tag() {
		return t_tag;
	}
	public void setT_tag(String t_tag) {
		this.t_tag = t_tag;
	}
	public int getT_cno() {
		return t_cno;
	}
	public void setT_cno(int t_cno) {
		this.t_cno = t_cno;
	}
	public String getT_comment() {
		return t_comment;
	}
	public void setT_comment(String t_comment) {
		this.t_comment = t_comment;
	}
	public String getT_id() {
		return t_id;
	}
	public void setT_id(String t_id) {
		this.t_id = t_id;
	}
	public String getT_pwd() {
		return t_pwd;
	}
	public void setT_pwd(String t_pwd) {
		this.t_pwd = t_pwd;
	}
}

 

VideoVO.java

package com.sist.vo;
/*
 * Table VIDEO이(가) 생성되었습니다.

이름        널?       유형             
--------- -------- -------------- 
V_NO      NOT NULL NUMBER         
V_TITLE   NOT NULL VARCHAR2(1000) 
V_POSTER  NOT NULL VARCHAR2(1000) 
V_VIDEO   NOT NULL VARCHAR2(1000) 
V_REGDATE          VARCHAR2(500)  
V_CONTENT          CLOB           
V_WRITER           VARCHAR2(500)  
V_HIT              NUMBER         
V_TAG              VARCHAR2(500)  
V_CNO              NUMBER         
V_COMMENT          CLOB           
V_ID               VARCHAR2(500)  
V_PWD              VARCHAR2(500)  
 */
public class VideoVO {
	private int v_no;
	private String v_title;
	private String v_poster;
	private String v_video;
	private String v_regdate;
	private String v_content;
	private String v_writer;
	private int v_hit;
	private String v_tag;
	private int v_cno;
	private String v_comment;
	private String v_id;
	private String v_pwd;
	public int getV_no() {
		return v_no;
	}
	public void setV_no(int v_no) {
		this.v_no = v_no;
	}
	public String getV_title() {
		return v_title;
	}
	public void setV_title(String v_title) {
		this.v_title = v_title;
	}
	public String getV_poster() {
		return v_poster;
	}
	public void setV_poster(String v_poster) {
		this.v_poster = v_poster;
	}
	public String getV_video() {
		return v_video;
	}
	public void setV_video(String v_video) {
		this.v_video = v_video;
	}
	public String getV_regdate() {
		return v_regdate;
	}
	public void setV_regdate(String v_regdate) {
		this.v_regdate = v_regdate;
	}
	public String getV_content() {
		return v_content;
	}
	public void setV_content(String v_content) {
		this.v_content = v_content;
	}
	public String getV_writer() {
		return v_writer;
	}
	public void setV_writer(String v_writer) {
		this.v_writer = v_writer;
	}
	public int getV_hit() {
		return v_hit;
	}
	public void setV_hit(int v_hit) {
		this.v_hit = v_hit;
	}
	public String getV_tag() {
		return v_tag;
	}
	public void setV_tag(String v_tag) {
		this.v_tag = v_tag;
	}
	public int getV_cno() {
		return v_cno;
	}
	public void setV_cno(int v_cno) {
		this.v_cno = v_cno;
	}
	public String getV_comment() {
		return v_comment;
	}
	public void setV_comment(String v_comment) {
		this.v_comment = v_comment;
	}
	public String getV_id() {
		return v_id;
	}
	public void setV_id(String v_id) {
		this.v_id = v_id;
	}
	public String getV_pwd() {
		return v_pwd;
	}
	public void setV_pwd(String v_pwd) {
		this.v_pwd = v_pwd;
	}
}

 

3. DB 넣기 (Manager, DAO)

NewsDAO

package com.sist.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.sist.vo.NewsVO;

public class NewsDAO {
	private Connection conn;
	private PreparedStatement ps;
	private final String URL="jdbc:oracle:thin:@211.238.142.195:1521:XE";
	public NewsDAO() {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(Exception ex) {}
	}
	public void getConnection() {
		try {
			conn=DriverManager.getConnection(URL,"hr","happy");
		}catch(Exception ex) {}
	}
	public void disConnection() {
		try {
			if(ps!=null) ps.close();
			if(conn!=null) conn.close();
		}catch(Exception ex) {}
	}
	
	public void newsInsert(NewsVO vo) {
		try {
			getConnection();
			String sql="INSERT INTO news (n_no,n_poster,n_precontent,n_title,n_poster2,n_regdate,n_content,n_writer) VALUES(?,?,?,?,?,?,?,?)";
			ps=conn.prepareStatement(sql);
			ps.setInt(1,  vo.getN_no());
			ps.setString(2, vo.getN_poster());
			ps.setString(3, vo.getN_precontent());
			ps.setString(4, vo.getN_title());
			ps.setString(5, vo.getN_poster2());
			ps.setString(6, vo.getN_regdate());
			ps.setString(7, vo.getN_content());
			ps.setString(8, vo.getN_writer());
			ps.executeUpdate();
			
			/*
			 * vo.setN_no(k);
					vo.setN_poster(poster.get(j).attr("src"));
					vo.setN_precontent(precontent.get(j).text());
					vo.setN_title(title.text());
					vo.setN_poster2(poster2.attr("src"));
					vo.setN_regdate(regdate.text());
					vo.setN_content(content.text());
					vo.setN_writer(writer.text());
			 */
			
			
		}catch(Exception ex) {
			System.out.println(ex.getMessage());
		}finally {
			disConnection();
		}
	}
}

 

NewsManager

package com.sist.manager;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import com.sist.dao.NewsDAO;
import com.sist.vo.NewsVO;

public class NewsManager {
	public void newsData() {
		try {
			NewsDAO dao = new NewsDAO();
			int k=1;
			for(int i=1; i<=24; i++) 
			{
				Document doc = Jsoup.connect("http://www.jobkorea.co.kr/goodjob/tip/120001?Page="+i).get();
				Elements link=doc.select("ul.joodJobList a");
				Elements poster = doc.select("p.thumb img");
				Elements precontent = doc.select("dd.tx");
			for(int j=0; j<link.size(); j++) {
				try {
					String nLink="http://www.jobkorea.co.kr"+link.get(j).attr("href");
					Document doc2 = Jsoup.connect(nLink).get();
					Element title = doc2.selectFirst("h3.tit");
					Element poster2 = doc2.selectFirst("div.viewWrap img");
					Element regdate = doc2.selectFirst("span.date");
					Element content = doc2.selectFirst("div.viewWrap");
					Element writer = doc2.selectFirst("span.cate");
					
					System.out.println("포스터:"+poster.get(j).attr("src"));
					System.out.println("pre내용:"+precontent.get(j).text());
					System.out.println("링크:"+link.get(j).attr("href"));
					System.out.println("제목:"+title.text());
					System.out.println("포스터2:"+poster2.attr("src"));
					System.out.println("작성일:"+regdate.text());
					System.out.println("내용:"+content.text());
					System.out.println("작가:"+writer.text());
					System.out.println("========================");
					
					NewsVO vo = new NewsVO();
					vo.setN_no(k);
					vo.setN_poster(poster.get(j).attr("src"));
					vo.setN_precontent(precontent.get(j).text());
					vo.setN_title(title.text());
					vo.setN_poster2(poster2.attr("src"));
					vo.setN_regdate(regdate.text());
					vo.setN_content(content.text());
					vo.setN_writer(writer.text());
	        		dao.newsInsert(vo);
					k++;
				}catch(Exception ex) {}
			}
			System.out.println("End...");
			}
		}catch(Exception ex) {}
	}
	
	public static void main(String[] args) {
		NewsManager n = new NewsManager();
		n.newsData();
	}
}

 

TipDAO

package com.sist.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.sist.vo.TipVO;

public class TipDAO {
	private Connection conn;
	private PreparedStatement ps;
	private final String URL="jdbc:oracle:thin:@211.238.142.195:1521:XE";
	public TipDAO() {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(Exception ex) {}
	}
	public void getConnection() {
		try {
			conn=DriverManager.getConnection(URL,"hr","happy");
		}catch(Exception ex) {}
	}
	public void disConnection() {
		try {
			if(ps!=null) ps.close();
			if(conn!=null) conn.close();
		}catch(Exception ex) {}
	}
	
	public void tipInsert(TipVO vo) {
		try {
			getConnection();
			String sql="INSERT INTO tip (t_no,t_poster,t_precontent,t_title,t_poster2,t_regdate,t_content,t_writer) VALUES(?,?,?,?,?,?,?,?)";
			ps=conn.prepareStatement(sql);
			ps.setInt(1,  vo.getT_no());
			ps.setString(2, vo.getT_poster());
			ps.setString(3, vo.getT_precontent());
			ps.setString(4, vo.getT_title());
			ps.setString(5, vo.getT_poster2());
			ps.setString(6, vo.getT_regdate());
			ps.setString(7, vo.getT_content());
			ps.setString(8, vo.getT_writer());
			ps.executeUpdate();
		}catch(Exception ex) {
			System.out.println(ex.getMessage());
		}finally {
			disConnection();
		}
	}
}

 

TipManager

package com.sist.manager;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import com.sist.dao.TipDAO;
import com.sist.vo.TipVO;

public class TipManager {
	public void tipData() {
		try {
			TipDAO dao = new TipDAO();
			int k=1;
			for(int i=1; i<=18; i++) {
				Document doc = Jsoup.connect("http://www.jobkorea.co.kr/goodjob/tip/120002?Page="+i).get();
				Elements poster = doc.select("p.thumb img");
				Elements precontent = doc.select("dd.tx");
				Elements link=doc.select("ul.joodJobList a");
			for(int j=0; j<link.size(); j++) {
				try {
					String tLink="http://www.jobkorea.co.kr"+link.get(j).attr("href");
					Document doc2 = Jsoup.connect(tLink).get();
					Element title = doc2.selectFirst("h3.tit");
					Element poster2 = doc2.selectFirst("div.viewWrap img");
					Element regdate = doc2.selectFirst("span.date");
					Element content = doc2.selectFirst("div.viewWrap");
					Element writer = doc2.selectFirst("span.cate");

					System.out.println("포스터:"+poster.get(j).attr("src"));
					System.out.println("pre내용:"+precontent.get(j).text());
					//System.out.println("링크:"+link.get(j).attr("href"));
					System.out.println("제목:"+title.text());
					System.out.println("포스터2:"+poster2.attr("src"));
					System.out.println("작성일:"+regdate.text());
					System.out.println("내용:"+content.text());
					System.out.println("작가:"+writer.text());
					System.out.println("========================");
					
					TipVO vo = new TipVO();
					vo.setT_no(k);
					vo.setT_poster(poster.get(j).attr("src"));
					vo.setT_precontent(precontent.get(j).text());
					vo.setT_title(title.text());
					vo.setT_poster2(poster2.attr("src"));
					vo.setT_regdate(regdate.text());
					vo.setT_content(content.text());
					vo.setT_writer(writer.text());
	        		dao.tipInsert(vo);
	        		k++;
				}catch(Exception ex) {}
			}
			System.out.println("End...");
			}
		}catch(Exception ex) {}
	}
	
	public static void main(String[] args) {
		TipManager t = new TipManager();
		t.tipData();
	}
}

 

VideoDAO

package com.sist.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.sist.vo.VideoVO;

public class VideoDAO {
	private Connection conn;
	private PreparedStatement ps;
	private final String URL="jdbc:oracle:thin:@211.238.142.195:1521:XE";
	public VideoDAO() {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(Exception ex) {}
	}
	public void getConnection() {
		try {
			conn=DriverManager.getConnection(URL,"hr","happy");
		}catch(Exception ex) {}
	}
	public void disConnection() {
		try {
			if(ps!=null) ps.close();
			if(conn!=null) conn.close();
		}catch(Exception ex) {}
	}
	
	public void videoInsert(VideoVO vo) {
		try {
			getConnection();
			String sql="INSERT INTO video (v_no,v_title,v_poster,v_video,v_writer) VALUES(?,?,?,?,?)";
			ps=conn.prepareStatement(sql);
			ps.setInt(1,  vo.getV_no());
			ps.setString(2, vo.getV_title());
			ps.setString(3, vo.getV_poster());
			ps.setString(4, vo.getV_video());
			ps.setString(5, vo.getV_writer());
			ps.executeUpdate();
		}catch(Exception ex) {
			System.out.println(ex.getMessage());
		}finally {
			disConnection();
		}
	}
}

 

VideoManager

package com.sist.manager;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Element;
import com.sist.dao.VideoDAO;
import com.sist.vo.VideoVO;

public class VideoManager {
	public void videoData() {
		VideoDAO dao = new VideoDAO();
		try {
			int k=1;
			for(int i=1; i<=10; i++) {
				Document doc = Jsoup.connect("https://www.catch.co.kr/News/CatchCast?CurrentPage="+i).get();
				Elements poster = doc.select("span.pic img");
				Elements title = doc.select("span.t1");
				Elements link=doc.select("ul.list_cast a");
			for(int j=0; j<poster.size(); j++) {
				try {
					String vLink="https://www.catch.co.kr"+link.get(j).attr("href");
					Document doc2 = Jsoup.connect(vLink).get();
					Element video = doc2.selectFirst("div.divide iframe");
					Element writer = doc2.selectFirst("p.t2");
					//System.out.println("번호"+k);
					System.out.println("제목:"+title.get(j).text());
					System.out.println("포스터:"+poster.get(j).attr("src"));
					//System.out.println("링크:"+link.get(j).attr("href"));
					System.out.println("비디오:"+video.attr("src"));
					System.out.println("작가:"+writer.text());
					System.out.println("========================");
					
					VideoVO vo = new VideoVO();
					vo.setV_no(k);
					vo.setV_title(title.get(j).text());
					vo.setV_poster(poster.get(j).attr("src"));
					vo.setV_video(video.attr("src"));
					vo.setV_writer(writer.text());
	        		dao.videoInsert(vo);
	        		k++;
				}catch(Exception ex) {}
			}
			System.out.println("End...");
			}
		}catch(Exception ex) {}
	}
	
	public static void main(String[] args) {
		VideoManager v = new VideoManager();
		v.videoData();
	}
}

/*
 * 
 * <iframe width="698" height="393" src="https://www.youtube.com/embed/Jw-OyheVJbM?rel=0" frameborder="0" 
 * allowfullscreen title="동영상" data-v-2d9b3d75>
 *
 */

 

 이용한 SQL

-- 오름차순
SELECT * FROM news ORDER BY n_no;

-- 컬럼갯수
SELECT COUNT(*) FROM news;

-- 테이블 전체 삭제
DROP TABLE tip;

-- 테이블의 데이터 선택 삭제
DELETE FROM video WHERE v_no=1;

-- 테이블의 데이터 전체 삭제
TRUNCATE TABLE news;

 


 

4. 리스트/상세페이지 출력

Java Resources/src/

Config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
   PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
   "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <properties resource="db.properties"/>
  <typeAliases>
  </typeAliases>
  <environments default="development">
    <environment id="development">
       <transactionManager type="JDBC"/>
       <dataSource type="POOLED">
           <property name="driver" value="${driver}"/>
           <property name="url" value="${url}"/>
           <property name="username" value="${username}"/>
           <property name="password" value="${password}"/>
       </dataSource>
    </environment>
  </environments>
  <mappers>
    <mapper resource="mapper/newsTipVideo-mapper.xml"/>
  </mappers>
</configuration>

db.properties

driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@211.238.142.195:1521:XE
username=hr
password=happy

 

dao

CreateSqlSessionFactory.java

package dao;
import java.io.*;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
public class CreateSqlSessionFactory {
	private static SqlSessionFactory ssf;
	static {
		try {
			Reader reader = Resources.getResourceAsReader("Config.xml");
			// 파싱
			ssf=new SqlSessionFactoryBuilder().build(reader);
		}catch(Exception ex) {
			System.out.println(ex.getMessage());
		}
	}
	public static SqlSessionFactory getSsf() {
		return ssf;
	}
}

NewsDAO.java

package dao;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import java.util.*;
import vo.*;
public class NewsDAO {
   private static SqlSessionFactory ssf;
   static {
	   ssf=CreateSqlSessionFactory.getSsf();
   }
  
   /*
    * <!-- 뉴스 리스트 -->
	<select id="newsListData" resultType="vo.NewsVO" parameterType="hashmap">
	
	<!-- 뉴스 페이지 수 -->
	<select id="newsTotalPage" resultType="int" parameterType="int">
	
	<!-- 뉴스 상세페이지 -->
	<select id="newsDetailData" resultType="vo.NewsVO" parameterType="int">
	
	<!-- 뉴스 조회수 -->
	<update id="newsHitIncrement" parameterType="int">
    * 
    */
   public static List<NewsVO> newsListData(Map map)
   {
	   SqlSession session=ssf.openSession();
	   List<NewsVO> list=session.selectList("newsListData",map);
	   session.close();
	   return list;
   }
   public static int newsTotalPage()
   {
	   SqlSession session=ssf.openSession();
	   int total=session.selectOne("newsTotalPage");
	   session.close();
	   return total;
   }
   
   public static NewsVO newsDetailData(int no) {
 		SqlSession session=ssf.openSession();
 		session.update("newsHitIncrement", no);
 		session.commit();
 		NewsVO vo=session.selectOne("newsDetailData", no);
 		session.close();
 		return vo;
 	}
   
   /*
   <!-- 팁 리스트 -->
	<select id="tipListData" resultType="vo.TipVO" parameterType="hashmap">
	
	<!-- 팁 페이지 수 -->
	<select id="tipTotalPage" resultType="int" parameterType="int">
	
	<!-- 팁 상세페이지 -->
	<select id="tipDetailData" resultType="vo.TipVO" parameterType="int">
	
	<!-- 팁 조회수 -->
	<update id="tipHitIncrement" parameterType="int">
	*/
   
   public static List<TipVO> tipListData(Map map){
	   SqlSession session=ssf.openSession();
	   List<TipVO> list=session.selectList("tipListData",map);
	   session.close();
	   return list;
   }
   public static int tipTotalPage() {
	   SqlSession session=ssf.openSession();
	   int total=session.selectOne("tipTotalPage");
	   session.close();
	   return total;
   }
   public static TipVO tipDetailData(int no) {
		SqlSession session=ssf.openSession();
		session.update("tipHitIncrement", no);
		session.commit();
		TipVO vo=session.selectOne("tipDetailData", no);
		session.close();
		return vo;
	}
   
   /*
	<!-- 비디오 리스트 -->
	<select id="videoListData" resultType="vo.VideoVO" parameterType="hashmap">
	
	<!-- 비디오 페이지 수 -->
	<select id="videoTotalPage" resultType="int" parameterType="int">
	
	<!-- 비디오 상세페이지 -->
	<select id="videoDetailData" resultType="vo.VideoVO" parameterType="int">
	
	<!-- 비디오 조회수 -->
	<update id="videoHitIncrement" parameterType="int">
   */
   public static List<VideoVO> videoListData(Map map){
	   SqlSession session=ssf.openSession();
	   List<VideoVO> list=session.selectList("videoListData",map);
	   session.close();
	   return list;
   }
   public static int videoTotalPage() {
	   SqlSession session=ssf.openSession();
	   int total=session.selectOne("videoTotalPage");
	   session.close();
	   return total;
   }
   
   public static VideoVO videoDetailData(int no) {
		SqlSession session=ssf.openSession();
		session.update("videoHitIncrement", no);
		session.commit();
		VideoVO vo=session.selectOne("videoDetailData", no);
		session.close();
		return vo;
	}
   
}

 

mapper

newsTipVideo-mapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="mapper.newsTipVideo-mapper">

	<!-- 뉴스 리스트 -->
	<select id="newsListData" resultType="vo.NewsVO" parameterType="hashmap">
	    SELECT n_no,n_poster,n_title,n_precontent,n_regdate,num
	    FROM (SELECT n_no,n_poster,n_title,n_precontent,n_regdate,rownum as num
	    FROM (SELECT n_no,n_poster,n_title,n_precontent,n_regdate 
	    FROM news ORDER BY n_no))
	    WHERE num BETWEEN #{start} AND #{end}
	</select>
	
	<!-- 뉴스 페이지 수 -->
	<select id="newsTotalPage" resultType="int" parameterType="int">
		SELECT CEIL(COUNT(*)/10.0) FROM news
	</select>

	<!-- 뉴스 상세페이지 -->
	<select id="newsDetailData" resultType="vo.NewsVO" parameterType="int">
	    SELECT n_no,n_poster2,n_title,n_regdate,n_content,n_writer,n_hit FROM news 
	    WHERE n_no=#{n_no}
	</select>
	
	<!-- 뉴스 조회수 -->
	<update id="newsHitIncrement" parameterType="int">
		UPDATE news SET
		n_hit=n_hit+1
		WHERE n_no=#{n_no}
	</update>
	
	<!-- 팁 리스트 -->
	<select id="tipListData" resultType="vo.TipVO" parameterType="hashmap">
	    SELECT t_no,t_poster,t_title,t_precontent,t_regdate,num
	    FROM (SELECT t_no,t_poster,t_title,t_precontent,t_regdate,rownum as num
	    FROM (SELECT t_no,t_poster,t_title,t_precontent,t_regdate 
	    FROM tip ORDER BY t_no))
	    WHERE num BETWEEN #{start} AND #{end}
	</select>
	
	<!-- 팁 페이지 수 -->
	<select id="tipTotalPage" resultType="int" parameterType="int">
		SELECT CEIL(COUNT(*)/10.0) FROM tip
	</select>
	
	<!-- 팁 상세페이지 -->
	<select id="tipDetailData" resultType="vo.TipVO" parameterType="int">
	    SELECT t_no,t_poster2,t_title,t_regdate,t_content,t_writer,t_hit FROM tip  
	    WHERE t_no=#{t_no}
	</select>
	
	<!-- 팁 조회수 -->
	<update id="tipHitIncrement" parameterType="int">
		UPDATE tip SET
		t_hit=t_hit+1
		WHERE t_no=#{t_no}
	</update>
	
	<!-- 비디오 리스트 -->
	<select id="videoListData" resultType="vo.VideoVO" parameterType="hashmap">
	    SELECT v_no,v_poster,v_title,v_writer,num
	    FROM (SELECT v_no,v_poster,v_title,v_writer,rownum as num
	    FROM (SELECT v_no,v_poster,v_title,v_writer 
	    FROM video ORDER BY v_no))
	    WHERE num BETWEEN #{start} AND #{end}
	</select>
	
	<!-- 비디오 페이지 수 -->
	<select id="videoTotalPage" resultType="int" parameterType="int">
		SELECT CEIL(COUNT(*)/20.0) FROM video
	</select>
	
	<!-- 비디오 상세페이지 -->
	<select id="videoDetailData" resultType="vo.VideoVO" parameterType="int">
	    SELECT v_no,v_title,v_video,v_writer,v_hit FROM video 
	    WHERE v_no=#{v_no}
	</select>
	
	<!-- 비디오 조회수 -->
	<update id="videoHitIncrement" parameterType="int">
		UPDATE video SET
		v_hit=v_hit+1
		WHERE v_no=#{v_no}
	</update>
</mapper>

 

model

MainModel.java

package model;

import javax.net.ssl.HttpsURLConnection;
import javax.servlet.http.HttpServletRequest;

import com.sist.controller.RequestMapping;

public class MainModel {
	
	@RequestMapping("main/main.do")
	public String main_page(HttpServletRequest request) {
		
		try {
			System.out.println("ssssssssssss");
			request.setAttribute("main_jsp", "../main/content.jsp");
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		return "../main/main.jsp";
	}
}

NewsModel.java

package model;

import javax.servlet.http.HttpServletRequest;
import com.sist.controller.RequestMapping;
import java.util.*;
import dao.*;
import vo.*;

public class NewsModel {	 
	 @RequestMapping("newsTipVideo/news.do")
	   public String newsList(HttpServletRequest request) {
		   String page=request.getParameter("page");
		   if(page==null)
			   page="1";
		   int curpage=Integer.parseInt(page);
		   Map map=new HashMap();
		   int rowSize=10;
		   int start=(rowSize*curpage)-(rowSize-1);
		   int end=rowSize*curpage;
		   
		   map.put("start",start);
		   map.put("end", end);
		   List<NewsVO> list=NewsDAO.newsListData(map);
		   // 총페이지
		   int totalpage=NewsDAO.newsTotalPage();
		   
		   request.setAttribute("curpage", curpage);
		   request.setAttribute("totalpage", totalpage);
		   request.setAttribute("list", list);
		   // include => news.jsp
		   request.setAttribute("main_jsp", "../newsTipVideo/news.jsp");
		   return "../main/main.jsp";
	   	}
	 
	 @RequestMapping("newsTipVideo/newsdetail.do")
	 	public String newsDetail(HttpServletRequest request) {
	 		String no=request.getParameter("no");
	 		NewsVO vo=NewsDAO.newsDetailData(Integer.parseInt(no));
	 		request.setAttribute("vo", vo);
	 		request.setAttribute("main_jsp", "../newsTipVideo/newsdetail.jsp");
	 		return "../main/main.jsp";
	 	}
	 
	 @RequestMapping("newsTipVideo/tip.do")
	   public String tipList(HttpServletRequest request) {
		   String page=request.getParameter("page");
		   if(page==null)
			   page="1";
		   int curpage=Integer.parseInt(page);
		   Map map=new HashMap();
		   int rowSize=10;
		   int start=(rowSize*curpage)-(rowSize-1);
		   int end=rowSize*curpage;
		   
		   map.put("start",start);
		   map.put("end", end);
		   List<TipVO> list=NewsDAO.tipListData(map);
		   // 총페이지
		   int totalpage=NewsDAO.tipTotalPage();
		   
		   request.setAttribute("curpage", curpage);
		   request.setAttribute("totalpage", totalpage);
		   request.setAttribute("list", list);
		   // include => news.jsp
		   request.setAttribute("main_jsp", "../newsTipVideo/tip.jsp");
		   return "../main/main.jsp";
	   	}
	 
	 @RequestMapping("newsTipVideo/tipdetail.do")
	 	public String tipDetail(HttpServletRequest request) {
	 		String no=request.getParameter("no");
	 		TipVO vo=NewsDAO.tipDetailData(Integer.parseInt(no));
	 		request.setAttribute("vo", vo);
	 		request.setAttribute("main_jsp", "../newsTipVideo/tipdetail.jsp");
	 		return "../main/main.jsp";
	 	}
	 
	 @RequestMapping("newsTipVideo/video.do")
	   public String videoList(HttpServletRequest request) {
		   String page=request.getParameter("page");
		   if(page==null)
			   page="1";
		   int curpage=Integer.parseInt(page);
		   Map map=new HashMap();
		   int rowSize=20;
		   int start=(rowSize*curpage)-(rowSize-1);
		   int end=rowSize*curpage;
		   
		   map.put("start",start);
		   map.put("end", end);
		   List<VideoVO> list=NewsDAO.videoListData(map);
		   // 총페이지
		   int totalpage=NewsDAO.videoTotalPage();
		   
		   request.setAttribute("curpage", curpage);
		   request.setAttribute("totalpage", totalpage);
		   request.setAttribute("list", list);
		   // include => news.jsp
		   request.setAttribute("main_jsp", "../newsTipVideo/video.jsp");
		   return "../main/main.jsp";
	  	}
	 	
	 @RequestMapping("newsTipVideo/videodetail.do")
	 	public String videoDetail(HttpServletRequest request) {
	 		String no=request.getParameter("no");
	 		VideoVO vo=NewsDAO.videoDetailData(Integer.parseInt(no));
	 		request.setAttribute("vo", vo);
	 		request.setAttribute("main_jsp", "../newsTipVideo/videodetail.jsp");
	 		return "../main/main.jsp";
	 	}
}

 

vo

NewsVO, TipVO, VideoVO

 

 

WebContent/newsTipVideo

news.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div style="height:30px"></div>
  <div class="row">
    <c:forEach var="vo" items="${list }">
      <div class="col-md-4">
	     <div class="thumbnail">
	      <a href="../newsTipVideo/newsdetail.do?no=${vo.n_no }">
	        <img src="${vo.n_poster }" alt="Lights" style="width:100%">
	        <div class="caption">
	          <p>${vo.n_title }</p>
	        </div>
	      </a>
       </div>
     </div>
    </c:forEach>
  </div>
  <div class="row">
    <div class="text-center">
      <a href="../newsTipVideo/news.do?page=${curpage>1?curpage-1:curpage }" class="btn btn-sm btn-info">이전</a>
       ${curpage } page / ${totalpage } pages
      <a href="../newsTipVideo/news.do?page=${curpage<totalpage?curpage+1:curpage }" class="btn btn-sm btn-success">다음</a>
    </div>
  </div>
</body>
</html>

newsdetail.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div class="container">
    <div class="row">
      <h1>내용보기</h1>
      <table class="table table-striped">
        <tr>
          <th class="text-center danger" width=20%>번호</th>
          <td class="text-center" width=30%>${vo.n_no }</td>
          <th class="text-center danger" width=20%>날짜</th>
          <td class="text-center" width=30%>
          <td class="text-center" width=30%>${vo.n_regdate }</td>
          </td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>작성</th>
          <td class="text-center" width=30%>${vo.n_writer }</td>
          <th class="text-center danger" width=20%>조회수</th>
          <td class="text-center" width=30%>${vo.n_hit }</td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>제목</th>
          <td class="text-left" colspan="3">${vo.n_title }</td>
        </tr>
        <tr>
        <center><img src="${vo.n_poster2 }" alt="Lights" style="width:100%"></center>
        </tr>
        <tr>
          <td class="text-left" colspan="4" valign="top" height="200">
            <pre style="white-space: pre-wrap;border: none;background-color: white">${vo.n_content }</pre>
          </td>
        </tr>
      </table>
    </div>
  </div>
</body>
</html>

 

tip.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div style="height:30px"></div>
  <div class="row">
    <c:forEach var="vo" items="${list }">
      <div class="col-md-4">
	     <div class="thumbnail">
	      <a href="../newsTipVideo/tipdetail.do?no=${vo.t_no }">
	        <img src="${vo.t_poster }" alt="Lights" style="width:100%">
	        <div class="caption">
	          <p>${vo.t_title }</p>
	        </div>
	      </a>
       </div>
     </div>
    </c:forEach>
  </div>
  <div class="row">
    <div class="text-center">
      <a href="../newsTipVideo/tip.do?page=${curpage>1?curpage-1:curpage }" class="btn btn-sm btn-info">이전</a>
       ${curpage } page / ${totalpage } pages
      <a href="../newsTipVideo/tip.do?page=${curpage<totalpage?curpage+1:curpage }" class="btn btn-sm btn-success">다음</a>
    </div>
  </div>
</body>
</html>

 

tipdetatil.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div class="container">
    <div class="row">
      <h1>내용보기</h1>
      <table class="table table-striped">
        <tr>
          <th class="text-center danger" width=20%>번호</th>
          <td class="text-center" width=30%>${vo.t_no }</td>
          <th class="text-center danger" width=20%>작성일</th>
          <td class="text-center" width=30%>
          <td class="text-center" width=30%>${vo.t_regdate }</td>
          </td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>작성</th>
          <td class="text-center" width=30%>${vo.t_writer }</td>
          <th class="text-center danger" width=20%>조회수</th>
          <td class="text-center" width=30%>${vo.t_hit }</td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>제목</th>
          <td class="text-left" colspan="3">${vo.t_title }</td>
        </tr>
        <tr>
        <center><img src="${vo.t_poster2 }" alt="Lights" style="width:100%"></center>
        </tr>
        <tr>
          <td class="text-left" colspan="4" valign="top" height="200">
            <pre style="white-space: pre-wrap;border: none;background-color: white">${vo.t_content }</pre>
          </td>
        </tr>
      </table>
    </div>
  </div>
</body>
</html>

 

video.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div style="height:30px"></div>
  <div class="row">
    <c:forEach var="vo" items="${list }">
      <div class="col-md-4">
	     <div class="thumbnail">
	      <a href="../newsTipVideo/videodetail.do?no=${vo.v_no }">
	        <img src="${vo.v_poster }" alt="Lights" style="width:100%">
	        <div class="caption">
	          <p>${vo.v_title }</p>
	        </div>
	      </a>
       </div>
     </div>
    </c:forEach>
  </div>
  <div class="row">
    <div class="text-center">
      <a href="../newsTipVideo/video.do?page=${curpage>1?curpage-1:curpage }" class="btn btn-sm btn-info">이전</a>
       ${curpage } page / ${totalpage } pages
      <a href="../newsTipVideo/video.do?page=${curpage<totalpage?curpage+1:curpage }" class="btn btn-sm btn-success">다음</a>
    </div>
  </div>
</body>
</html>

 

videodetail.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  <div class="container">
    <div class="row">
      <h1>내용보기</h1>
      <table class="table table-striped">
        <tr>
          <th class="text-center danger" width=20%>번호</th>
          <td class="text-center" width=30%>${vo.v_no }</td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>이름</th>
          <td class="text-center" width=30%>${vo.v_writer }</td>
          <th class="text-center danger" width=20%>조회수</th>
          <td class="text-center" width=30%>${vo.v_hit }</td>
        </tr>
        <tr>
          <th class="text-center danger" width=20%>제목</th>
          <td class="text-left" colspan="3">${vo.v_title }</td>
        </tr>
        <tr>
          <td class="text-left" colspan="4" valign="top" height="200">
          <iframe id="player" type="text/html" width="640" height="360" src="${vo.v_video }" frameborder="0"></iframe>
          </td>
        </tr>
      </table>
    </div>
  </div>
</body>
</html>

 

 

WebContent/main/

header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">

</script>
</head>
<body>
	<header>
        <!-- Header Start -->
       <div class="header-area" style="background-color: #5076A0;">
            <div class="main-header ">
                <div class="header-top black-bg d-none d-md-block">
                   <div class="container">
                       <div class="col-xl-12">
                            <div class="row d-flex justify-content-between align-items-center">
                                <div class="header-info-left">
                                    <ul>     
                                        <li><img src="assets/img/icon/header_icon1.png" alt="">34ºc, Sunny </li>
                                        <li><img src="assets/img/icon/header_icon1.png" alt="">Tuesday, 18th June, 2019</li>
                                    </ul>
                                </div>
                                <div class="header-info-right">
                                    <ul class="header-social">    
                                        <li><a href="#"><i class="fab fa-twitter"></i></a></li>
                                        <li><a href="#"><i class="fab fa-instagram"></i></a></li>
                                       <li> <a href="#"><i class="fab fa-pinterest-p"></i></a></li>
                                    </ul>
                                </div>
                            </div>
                       </div>
                   </div>
                </div>
                <div class="header-mid d-none d-md-block">
                   <div class="container">
                        <div class="row d-flex align-items-center">
                            <!-- Logo -->
                            <div class="col-xl-3 col-lg-3 col-md-3">
                                <div class="logo">
                                    <a href="index.html"><img src="../image/logo.png" width=400px></a>
                                </div>
                            </div>
                            <div class="col-xl-9 col-lg-9 col-md-9">
                                <div class="header-banner f-right ">
                                    <img src="assets/img/hero/header_card.jpg" alt="">
                                </div>
                            </div>
                        </div>
                   </div>
                </div>
               <div class="header-bottom header-sticky">
                    <div class="container">
                        <div class="row align-items-center">
                            <div class="col-xl-10 col-lg-10 col-md-12 header-flex">
                                <!-- sticky -->
                                    <div class="sticky-logo">
                                        <a href="index.html"><img src="../image/logo.png" width=300px></a>
                                    </div>
                                <!-- Main-menu -->
                                <div class="main-menu d-none d-md-block">
                                    <nav>                  
                                        <ul id="navigation">    
                                            <li><a href="../main/main.do">홈</a></li>
                                            <li><a href="categori.html">채용공고</a>
                                            	<ul class="submenu">
                                                    <li><a href="#">100대기업 공채</a></li>
                                                    <li><a href="#">인턴채용</a></li>
                                                    <li><a href="#">공채달력</a></li>
                                                    <li><a href="details.html">상시모집</a></li>
                                                </ul>
                                            </li>
                                            <!-- 
                                            <li><a href="about.html">취업꿀팁</a>
                                            	<ul class="submenu">
                                                    <li><a href="../selfletter/letter.do">합격자소서</a></li>
                                                    <li><a href="../company/company.do">기업·면접후기</a></li>
                                                    <li><a href="../newsTipVideo/news.do">취업뉴스</a></li>
                                                    <li><a href="../newsTipVideo/tip.do">취업꿀팁</a></li>
                                                    <li><a href="../newsTipVideo/video.do">취업영상</a></li>
                                                    <li><a href="details.html">추가요망</a></li>
                                                </ul>
                                            </li>
                                             -->
                                            <li><a href="about.html">취업꿀팁</a>
                                            	<ul class="submenu">
                                                    <li><a href="../selfletter/letter.do">합격자소서</a></li>
                                                    <li><a href="../company/company.do">기업·면접후기</a></li>
                                                    <li><a href="../newsTipVideo/news.do">취업뉴스</a></li>
                                                    <li><a href="../newsTipVideo/tip.do">취업꿀팁</a></li>
                                                    <li><a href="../newsTipVideo/video.do">취업영상</a></li>
                                                    <li><a href="details.html">추가요망</a></li>
                                                </ul>
                                            </li>
                                            <li><a href="latest_news.html">공모전</a>
                                            	<ul class="submenu">
                                                    <li><a href="#">추가요망</a></li>
                                                    <li><a href="#">추가요망</a></li>
                                                    <li><a href="#">추가요망</a></li>
                                                </ul>
                                            </li>
                                            <li><a href="../jobKnowledge/list.do">Job 지식인</a>				<!-- 잡지식인 메인페이지 : 게시글 리스트 출력 -->
                                            	<ul class="submenu">
                                                    <li><a href="../jobKnowledge/answer.do">질문하기</a></li>
                                                    <li><a href="../jobKnowledge/profile.do">지식인 프로필</a></li>
                                                    <li><a href="../jobKnowledge/test.do">테스트</a></li>
                                                </ul>
                                            </li>
                                            <li><a href="#">로그인</a>
                                                <ul class="submenu">
                                                     <c:if test="${sessionScope.id!=null }">
	                                                   <c:if test="${sessionScope.admin=='n'}">
												            <li><a href="../resume/resume.do">내 이력서</a></li>
												          </c:if>
											           <li><a href="../user/join.do">회원수정</a></li>
											         </c:if>
											         <c:if test="${sessionScope.id==null }">
	                                                   <li><a href="../user/login_form.do">로그인</a></li>
												       <li><a href="../user/join.do">회원가입</a></li>
                                                     </c:if>
	                                                 <c:if test="${ sessionScope.id!=null}">
													      <c:if test="${sessionScope.admin=='n'}">
												            <li><a href="#">마이페이지</a></li>
												          </c:if>
												          <c:if test="${sessionScope.admin=='y'}">
												            <li><a href="#">관리자페이지</a></li>
												          </c:if>
	      											 </c:if>
                                                </ul>
                                            </li>
                                        	<li>
                                            <c:if test="${sessionScope.id!=null }">
											  <form action="../user/logout.do"><%-- get(생략이 가능) --%>
											    <div class="text-right" >
											      ${sessionScope.name }님 
											      <button class="genric-btn danger radius small">로그아웃</button>
											    </div>
											  </form>
 											</c:if>
 											</li>
                                        </ul>
                                    </nav>
                                </div>
                            </div>             
                            <div class="col-xl-2 col-lg-2 col-md-4">
                                <div class="header-right-btn f-right d-none d-lg-block">
                                    <i class="fas fa-search special-tag"></i>
                                    <div class="search-box">
                                        <form action="#">
                                            <input type="text" placeholder="Search">
                                            
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <!-- Mobile Menu -->
                            <div class="col-12">
                                <div class="mobile_menu d-block d-md-none"></div>
                            </div>
                        </div>
                    </div>
               </div>
            </div>
       </div>
        <!-- Header End -->
    </header>
</body>
</html>

 

5. 깃허브 업로드

오류

1. 톰캣추가: Libraries 밑라이브러리 아무거나 오른쪽클릭- Build Path - Configure Build Path-Add Library-Server Runtime

2. web.xml에서 contextConfigLocation, path 경로 바꿔주기

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>1project</display-name>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>com.sist.controller.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/Users/yongpro/SecondTeamProject/Team4thProject/WebContent/WEB-INF/application-context.xml</param-value>
    </init-param>
    <init-param>
  	  <param-name>path</param-name>
  	  <param-value>/Users/yongpro/SecondTeamProject/Team4thProject/src</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>dispatcher</servlet-name>
  	<url-pattern>*.do</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

3. WEB-INF의 lib폴더에 yongpro -> yong폴더에있는 ojdbc6.jar, Controller.jar복사해서 

/Users/yongpro/SecondTeamProject/Team4thProject/WebContent/WEB-INF/lib 에있는 Controller.jar 지우고 두개 붙여넣기

F5눌려주기

반응형
Comments