๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๊ฐœ๋ฐœ์–ธ์–ด/JSP

[JSP/Servlet] ํŒŒ์ผ์—…๋กœ๋“œ ๊ตฌํ˜„ํ•˜๊ธฐ +ํŽ˜์ด์ง•

by yunamom 2022. 6. 13.
๋ฐ˜์‘ํ˜•

์•ˆ๋…•ํ•˜์„ธ์š” yunamom ์ž…๋‹ˆ๋‹ค :D

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ํŒŒ์ผ์—…๋กœ๋“œ(Mysql) , ํŒŒ์ผ ๋ชฉ๋ก, ํŒŒ์ผ ์ƒ์„ธ๋ณด๊ธฐํ™”๋ฉด์„ ๊ตฌํ˜„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป

๊ตฌํ˜„ํ•  ํŒŒ์ผ๋ชฉ๋ก (images ํด๋” ์ƒ์„ฑํ•˜๊ธฐ)
ํŒŒ์ผ์—…๋กœ๋“œ ํ™”๋ฉด
ํŒŒ์ผ ๋ชฉ๋ก
ํŒŒ์ผ ์ƒ์„ธ๋ณด๊ธฐ

Mysql ํ…Œ์ด๋ธ” ์ƒ์„ฑ ๋ฐ webapp/images ํด๋” ์ƒ์„ฑ

CREATE TABLE fileboard(
 unq INT unsigned NOT NULL AUTO_INCREMENT,
 name VARCHAR(50),
 title VARCHAR(100),
 fileName VARCHAR(200),
 hits INT unsigned default '0',
 uploadDate DATETIME,
 PRIMARY KEY(unq)
 );

 INSERT INTO fileboard VALUES(1, 'ํ…Œ์ŠคํŠธ', 'ํŒŒ์ผ์—…๋กœ๋“œ ํ…Œ์ŠคํŠธ ์ž…๋‹ˆ๋‹ค.', 'file2.png', 0, sysdate());

 controller/Controller.java

[ OPEN ]
package 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 service.FileListService;
import service.FileSelectOneService;
import service.Service;
import service.UploadService;


@WebServlet("*.do")
public class Controller extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		execute(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		execute(request, response);
	}
	
	private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
		String uri = request.getRequestURI();
		String conPath = request.getContextPath();
		String command = uri.substring(conPath.length());
		
		String site = null;
		Service service = null;
		switch(command) {
		case "/Main.do"          :
			site = "fileupload/main.jsp";
			break;
			
		case "/Upload.do"        :
			site = "fileupload/upload.jsp";
			break;	
			
		case "/FileList.do"      :
			service = new FileListService();
			service.execute(request, response);
			site = "fileupload/list.jsp";
			break;
			
		case "/FileSelect.do"     :
			service = new FileSelectOneService();
			service.execute(request, response);
			site = "fileupload/detail.jsp";
			break;
			
		case "/UploadService.do" :
			service = new UploadService();
			service.execute(request, response);
			site = "fileupload/main.jsp";
			break;
		}
		
		RequestDispatcher dis = request.getRequestDispatcher(site);
		dis.forward(request, response);

	}
}

 model/File.java 

[ OPEN ]
package model;


public class File {

	private int no; //๊ฒŒ์‹œ๋ฌผ๋ฒˆํ˜ธ
	private int unq;
	private String name;
	private String title;
	private String fileName;
	private int hits;
	private String uploadDate;

	
	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}
	
	public int getUnq() {
		return unq;
	}

	public void setUnq(int unq) {
		this.unq = unq;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public int getHits() {
		return hits;
	}

	public void setHits(int hits) {
		this.hits = hits;
	}

	public String getUploadDate() {
		return uploadDate;
	}

	public void setUploadDate(String string) {
		this.uploadDate = string;
	}
}

 model/Paging.java 

[ OPEN ]
package model;

public class Paging {

	private int view;
	private int range;
	private int start;
	private int end;
	private int endPage;

	public int getView() {
		return view;
	}

	public void setView(int view) {
		this.view = view;
	}

	public int getRange() {
		return range;
	}

	public void setRange(int range) {
		this.range = range;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getEnd() {
		return end;
	}

	public void setEnd(int end) {
		this.end = end;
	}

	public int getEndPage() {
		return endPage;
	}

	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}
}

 model/FileDAO.java 

[ OPEN ]
package model;

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 javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;




public class FileDAO {
	
	private Connection conn = null;
	private PreparedStatement pstmt = null;
	private ResultSet rs = null;
	private int result = 0;
	String mvURL = null;

	private static FileDAO instance = new FileDAO();
	
	public static FileDAO getInstance() {
		return instance;
	}
	
	//DB ์—ฐ๊ฒฐํ•˜๊ธฐ
	public static Connection getConnection() throws Exception {
				
		String url = "jdbc:mysql://localhost:3306/database"; //๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ด๋ฆ„
		String id = "root";
		String pw = "root";
		//์ ‘์†๋“œ๋ผ์ด๋ฒ„ ์—ฐ๊ฒฐ
		Class.forName("com.mysql.cj.jdbc.Driver");
		//์ ‘์†์ •๋ณด ์„ธํŒ…
		Connection con = DriverManager.getConnection(url, id, pw);
		//์ ‘์†ํ•œ MySQL์˜ SQL์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์œ„ํ•œ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ํ™•๋ณด
		return con;
		
	}
	
	//DB ์—ฐ๊ฒฐ ์ข…๋ฃŒํ•˜๊ธฐ
	public void close() throws SQLException {
		if(rs != null) rs.close();
		if(pstmt != null) pstmt.close();
		if(conn != null) conn.close();
	}
	
	//ํŒŒ์ผ์—…๋กœ๋“œ ํ•˜๊ธฐ 
	public int insert(String name, String title, String file){
		
		try {
			
		conn = getConnection();
		
		String sql = " INSERT INTO fileboard ";
		       sql+= " (name, title, fileName, hits, uploadDate) ";
               sql+= " VALUES( ?, ?, ?, 0, sysdate() )";
		
		pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, name);
		pstmt.setString(2, title);
		pstmt.setString(3, file);
		
		result = pstmt.executeUpdate();
		
		close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	//ํŒŒ์ผ์ด๊ฐฏ์ˆ˜
	public int countAll() {
		int total = 0;
		try {
			conn = getConnection();
			
			String sql = "SELECT COUNT(*) FROM fileboard";
			pstmt = conn.prepareStatement(sql);
			rs = pstmt.executeQuery();
			if(rs.next()) total = rs.getInt(1);
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		
		return total;
	}
	
	//ํŒŒ์ผ๋ชฉ๋ก ์กฐํšŒ (start, end)
	public ArrayList<File> selectAll(int start, int end, int total) {

		ArrayList<File> list = new ArrayList<>();
		
		
		try {
			conn = getConnection();		
			
			String sql = " SELECT ";
			       sql+= " unq, ";
			       sql+= " name, ";
			       sql+= " title, ";
			       sql+= " fileName, ";
			       sql+= " hits, ";
			       sql+= " DATE_FORMAT(uploadDate, '%y/%m/%d')uploadDate ";
			       sql+= " FROM fileboard ";
			       sql+= " ORDER BY unq DESC LIMIT ?,?";
			pstmt = conn.prepareStatement(sql);
			pstmt.setInt(1, start);
			pstmt.setInt(2, end);
			rs = pstmt.executeQuery();
			int count = start;
			while(rs.next()) {
				
				File file = new File();
				file.setNo(total-count++);
				file.setUnq(rs.getInt(1));
				file.setName(rs.getString(2));
				file.setTitle(rs.getString(3));
				file.setFileName(rs.getString(4));
				file.setHits(rs.getInt(5));
				file.setUploadDate(rs.getString(6));
				list.add(file);
			}
			
			close();
		
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;

	}
	//์„ ํƒ๋œ ํŒŒ์ผ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
	public File selectOne(String unq) {
		
		File file = new File();
		try {
			conn = getConnection();
			
			
			String sql = " SELECT ";
			       sql+= " unq, ";
			       sql+= " name, ";
			       sql+= " title, ";
			       sql+= " fileName, ";
			       sql+= " hits, ";
			       sql+= " DATE_FORMAT(uploadDate, '%y/%m/%d')uploadDate ";
			       sql+= " FROM fileboard ";
			       sql+= " WHERE unq ="+unq;
			pstmt = conn.prepareStatement(sql);
			
			rs = pstmt.executeQuery();
			rs.next();
			
			
			file.setUnq(rs.getInt(1));
			file.setName(rs.getString(2));
			file.setTitle(rs.getString(3));
			file.setFileName(rs.getString(4));
			file.setHits(rs.getInt(5));
			file.setUploadDate(rs.getString(6));				
			
			
			close();	
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return file;
	}

	public void updateHit(String unq) {
		// ์กฐํšŒ์ˆ˜์ฆ๊ฐ€
		try {
			conn = getConnection();
			String sql = " UPDATE fileboard ";
			       sql+= " SET hits = hits+1 ";
			       sql+= " WHERE unq ="+unq;
			pstmt = conn.prepareStatement(sql);
					
			pstmt.executeUpdate();
			close();
		
			       
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}
}

 service/Service.java 

[ OPEN ]
package service;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public interface Service {
	
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException;

}

 service/UploadService.java 

[ OPEN ]
package service;


import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oreilly.servlet.MultipartRequest;
import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;

import model.FileDAO;


public class UploadService implements Service {
       
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException {
   	 
	   	String saveDir = request.getSession().getServletContext().getRealPath("images");
	   	System.out.println("์ ˆ๋Œ€๊ฒฝ๋กœ : " + saveDir);
	   	
	   	int maxSize = 1024*1024*15; 
		String encoding = "UTF-8";
			
			// saveDir: ๊ฒฝ๋กœ
			// maxSize: ํฌ๊ธฐ์ œํ•œ ์„ค์ •
			// encoding: ์ธ์ฝ”๋”ฉํƒ€์ž… ์„ค์ •
			// new DefaultFileRenamePolicy(): ์ค‘๋ณต์ด๋ฆ„ ๋ฐฉ์ง€	
			
		MultipartRequest multi = new MultipartRequest(request, saveDir, maxSize, encoding, new DefaultFileRenamePolicy());
		/* URL check */
		String uri = request.getRequestURI();
		String con = request.getContextPath();
		String command = uri.substring(con.length());
		System.out.println(command);
		
		String name = multi.getParameter("name");
		String title = multi.getParameter("title");
		String file = multi.getFilesystemName("file");
		
		
		FileDAO dao = FileDAO.getInstance(); // static ์˜์—ญ์— ์˜ฌ๋ ค์ง„ ๊ฐ์ฒด๋ฅผ ๋ฉ”์†Œ๋“œ๋กœ ์–ป์–ด์™€์„œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ ˆ์•ฝํ•˜๋Š” ์‹ฑ๊ธ€ํ†ค ํŒจํ„ด
		
		int result = dao.insert(name, title, file);
	
		if(result > 0) {
			System.out.println("์ €์žฅ์™„๋ฃŒ!");			
		}else {
			System.out.println("์ €์žฅ์‹คํŒจ!");
		}
	}	
}

 service/FileListService.java 

[ OPEN ]
package service;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.File;
import model.FileDAO;
import model.Paging;


public class FileListService implements Service {
       
	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) {
		
		FileDAO dao = FileDAO.getInstance();
		
		String view = request.getParameter("view");
		
		/* ํ˜„์žฌ ํŽ˜์ด์ง€ */
		int viewPage = (view == null) ? 1 : Integer.parseInt(view);
		
		/* ํ•œ ๋ธ”๋Ÿญ( range : ๋ฒ”์œ„ ) ์˜ ํŽ˜์ด์ง€ ์ˆ˜ */
		int rangeSize = 5; 
		
		int end = 5; // ํ•œ ํŽ˜์ด์ง€์˜ ๊ฒŒ์‹œ๋ฌผ ์ˆ˜ 
		int start = (viewPage-1)*rangeSize;
		
		
		/* ์ด ํŒŒ์ผ ๊ฐฏ์ˆ˜ */
		int total = dao.countAll();
		// ๋งˆ์ง€๋ง‰ ํŽ˜์ด์ง€ 
		int endPage = (int)Math.ceil((double)total/5);		
		
		// ( range : ๋ฒ”์œ„ ) 
		int Range = (viewPage % rangeSize == 0)?viewPage/rangeSize:(viewPage/rangeSize)+1;
		// ์ด์ „๋ฒ„ํŠผ ๋ธ”๋Ÿญ( range : ๋ฒ”์œ„ ) 
		int startRange = (Range-1)*rangeSize+1;
		// ๋‹ค์Œ๋ฒ„ํŠผ ๋ธ”๋Ÿญ( range : ๋ฒ”์œ„ ) 
		int endRange = startRange + rangeSize-1;
		// ๋งˆ์ง€๋ง‰ ๋ธ”๋ฝ์—์„œ ์ดํŽ˜์ด์ง€์ˆ˜๋ฅผ ๋„˜์–ด๊ฐ€๋ฉด ๋ ํŽ˜์ด์ง€๋ฅผ ๋งˆ์ง€๋ง‰ ํŽ˜์ด์ง€ ์ˆซ์ž๋กœ ๋„ฃ์–ด์ค๋‹ˆ๋‹ค. 
		endRange = (endRange >= endPage) ? endPage : endRange;
		
		ArrayList<File> list = dao.selectAll(start, end, total);
		
		
		Paging paging = new Paging();			
		paging.setView(viewPage);
		paging.setRange(rangeSize);
		paging.setStart(startRange);
		paging.setEnd(endRange);
		paging.setEndPage(endPage);
		
		request.setAttribute("list", list);
		request.setAttribute("paging", paging);	
	}
}

 service/FileSelectoneService.java 

[ OPEN ]
package service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.File;
import model.FileDAO;


public class FileSelectOneService implements Service {

    
    public void execute(HttpServletRequest request, HttpServletResponse response) {
    	String unq = request.getParameter("unq");
    	FileDAO dao = FileDAO.getInstance();
    	
    	dao.updateHit(unq); // ์กฐํšŒ์ˆ˜์ฆ๊ฐ€ 
    	request.setAttribute("file", dao.selectOne(unq));
    }
}

 index.jsp 

[ OPEN ]
<%@ 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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<% response.sendRedirect("Main.do"); %>
</body>
</html>

 css/style.css 

[ OPEN ]
@charset "UTF-8";

*{
	margin: 0;
	padding: 0;
}
body{
	background: #ebecfa;
}
header{
	height: 100px;
	line-height: 100px;
	background: #444;
	text-align: center;
}
nav ul{
	height: 50px;
	line-height: 50px;
	background: #837b93;
}
li{
	float: left;
	list-style: none;
	padding: 0 10px;
}
a{
	text-decoration: none;
	color: rgb(104, 105, 105);
	font-weight: 900;
}
li a{
	color: #fff;
}
.Boxfile{ /* ์ •์ค‘์•™ */
	margin: 3rem;
	display: grid;
	place-items: center;
	min-height: 50vh;
	background-color: rgba(255,255,255,0.7);
	padding: 1rem;
	border-radius: 0.3rem;
}
.input{
	font-size: 1rem;
	padding: 0.5rem 1rem;
	border-radius: 0.3rem;
	border: 1px solid #333;
}
.Boxbtn{
	text-align: center;
	padding: 1rem;
}
.btn{
	padding: 0.4rem 1rem;
	cursor: pointer;
	border-radius: 0.3rem;
	border: 1px solid #8e8f8f;
}
.btn:hover{
	opacity: 0.6;
}
.imgList{
	width:50px;
	height:50px;
}
.wrapper{
	display: flex;
	justify-content: center;
	align-items: center;
	margin:1rem;
}
section{
	height: 100%;
	width: 100%;
}
.title{
	margin: 3rem;
	font-size: 30px;
	font-weight: 900;
	text-align: center;
	color: #615d6f;
}
.legend{
	font-size: 20px;
	text-align: center;
	font-weight: 900;
	color: #615d6f;
}
.Boxtitle{
	width:50px;
	height:50px;
}
.Box{
	height: 300px;
}
.Box table{
	width: 600px;
	text-align: center;
}
.Box table, .Box th, .Box td{
	border: 1px solid #544952;
	border-collapse: collapse;
	padding: 0.5rem;
}
.unq{
	font-size: 15px;
	color: #aeb0b2;
}
.Box th{
	background: #837b93;
	color: #fff;
}

.range{
	margin: 0 10px;
	font-size: 20px;
	cursor: pointer;
	
}
.range:hover{
	opacity: 0.6;
}
.Boxrange{
	width: 200px;
	text-align: center;
}
.Boxprev{
	width: 80px;
	text-align: right;
}
.Boxnext{
	width: 80px;
	text-align: left;
}
.Filetitle {
    display: inline-block;
    width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    text-align: left;
}
.Filetitle:hover{
	opacity: 0.6;
}
.Filetitle a{
	font-weight: 0;
}

.Boxdetail{
	width: 100%;
	text-align:center;
	background: #fff;
	font-size: 12px;
	color: #333;
}
.Boxfile img{
	width: 300px;
	
	
}
/* ๋ง์ค„์ž„ํ‘œ */
.target {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
}

 include/topmenu.jsp 

[ OPEN ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>topmenu</title>
</head>
<body>

<nav>
	<ul>
		<li><a href="FileList.do">List</a></li>
		<li><a href="Upload.do">Upload</a></li>
		<li><a href="Main.do">Main</a></li>
	</ul>
</nav>
</body>
</html>

 fileupload/main.jsp 

[ OPEN ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css">
<title>๋ฉ”์ธ</title>
</head>
<body>
<%@ include file="/include/topmenu.jsp" %>
<section>
<div class="title">* ํŒŒ์ผ ์—…๋กœ๋“œ ๋ฉ”์ธ *</div>
</section>
</body>
</html>

 fileupload/upload.jsp 

[ OPEN ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css?ver=1">
<script src="script/script.js"></script>
<title>ํŒŒ์ผ ์—…๋กœ๋“œ</title>
</head>
<body>
<%@ include file="/include/topmenu.jsp" %>
<section>
<div class="title"> </div>
<div class="wrapper">
<fieldset >
	<legend class="legend">* ํŒŒ์ผ ์—…๋กœ๋“œ *</legend>
	
	<form class="Boxfile" method="post" action="UploadService.do" enctype="multipart/form-data">
	<!-- ์„œ๋ฒ„์— ํŒŒ์ผ์„ ๋ณด๋‚ผ๊ฒƒ ์ด๋ผ๊ณ  ์•Œ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด enctype ์˜ต์…˜์— multipart/form-data ์„ ์–ธํ•ด์ฃผ๊ธฐ -->
	<table>
		<tr>
		<td>Title : </td>
		<td><input class="input" type="text" name="title"/></td>
		</tr>
		<tr>
		<td>Name  : </td>
		<td><input class="input" type="text" name="name"/></td>
		</tr>
		<tr>
		<td>File  : </td>
		<td><input type="file" name="file"/></td>
		</tr>
		<tr>
		<td colspan="2" class="Boxbtn">
		<Button class="btn" type="submit" >Upload</Button>
		<Button class="btn" type="Button" onclick="location='Upload.do'">Reset</Button>
		</td>
		</tr>
	</table>
	</form>
	
</fieldset>
</div>
</section>
</body>
</html>

 fileupload/list.jsp 

[ OPEN ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="C"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css?ver=1">
<meta charset="UTF-8">
<title>File List</title>
</head>
<body>
<%@ include file="/include/topmenu.jsp" %>
<section>
<div class="title"><img class="Boxtitle" src="images/file2.png"/>
</div>
<div class="wrapper">
	<div class="Box">
	<table>
		<tr>
			<th>No</th>
			<th>Title</th>
			<th>Name</th>
			<th>Date</th>
			<th>hits</th>
		</tr>
		<C:forEach var="i" items="${list }">
			<tr>
				<td class="unq">${i.no }</td>
				<td><a href="FileSelect.do?unq=${i.unq }" class="Filetitle">
				${i.title }</a></td>
				<td><p class="target" style="width:80px">${i.name }</p></td>
				<td><p class="target" style="width:80px">${i.uploadDate }</p></td>
				<td>${i.hits }</td>
			</tr>
		</C:forEach>
	</table>
	</div>
</div>
<div class="wrapper">
<div class="Boxprev">
<C:if test="${paging.start != 1 }">
<a class="range" href="?view=${paging.start-1}">์ด์ „</a>
</C:if>
</div>

<div class="Boxrange">
<C:forEach var="status" begin="${paging.start }" end="${paging.end }">
<a class="range" href="?view=${status }">${status }</a>
</C:forEach>

</div>

<div class="Boxnext">
<C:if test="${paging.end < paging.endPage}">
<a class="range" href="?view=${paging.end+1}">๋‹ค์Œ</a>
</C:if>
</div>
</div>
</section>
</body>
</html>

 fileupload/detail.jsp 

[ OPEN ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="C"%>

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css?ver=1">
<meta charset="UTF-8">
<title>File Detail</title>
</head>
<body>
<%@ include file="/include/topmenu.jsp" %>
<section>
<div class="title"> </div>
<div class="wrapper">
<fieldset >
	<legend class="legend">์ œ๋ชฉ : ${file.title }</legend>
	<div class="Boxdetail">์ž‘์„ฑ์ž : ${file.name } โˆ™ ${file.uploadDate} โˆ™ ์กฐํšŒ์ˆ˜ : ${file.hits }</div>
	<div class="Boxfile">
	<img src="images/${file.fileName }"/>	
	</div>
</fieldset>
</div>
	<div class="Boxbtn">
		<Button class="btn" type="Button" onclick="history.back()">๋ชฉ๋ก์œผ๋กœ</Button>
	</div>

</section>
</body>
</html>

 WEB-INF/lib/web.xml 

[ OPEN ]
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
id="WebApp_ID" version="4.0">
  <display-name>file</display-name>
  <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>

 WEB-INF/lib 

cos.jar
0.05MB
jstl.jar
0.02MB
mysql-connector-java-8.0.27.jar
2.36MB
standard.jar
0.38MB

ํ…Œ์ŠคํŠธ์—…๋กœ๋“œ ํŒŒ์ผ

file2.png
0.00MB


์ด๋ ‡๊ฒŒ ํŒŒ์ผ ์—…๋กœ๋“œ/ํŒŒ์ผ ๋ชฉ๋ก/์ƒ์„ธ๋ณด๊ธฐ๋ฅผ ๊ตฌํ˜„ํ•ด๋ณด์•˜๋Š”๋ฐ์š”,

๋‹ค์Œ ๊ธ€์—์„œ๋Š” ํŒŒ์ผ ์ˆ˜์ •/์‚ญ์ œํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•˜์—ฌ  ํฌ์ŠคํŒ…ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป๐Ÿ˜Š

 

 

 

 

 

300x250

์ฝ”๋“œ