기록해! 정리해!

myBatis2 (4)- 자료실(사진) 본문

SpringBoot

myBatis2 (4)- 자료실(사진)

zsuling 2022. 10. 13. 12:19

1. 폴더 생성

2. form_psd.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 align="center">
<h2> 성적 저장하기 </h2>

<form action="form_psd_ok.do" method="post"
                              enctype="multipart/form-data">
<table border=1 >
<tr> <td > 번호 </td><td > <input type=text name="sno" >  </td> </tr>
<tr> <td> 사진 </td> <td > <input type=file name="file"></td> </tr>

<tr> <td colspan=2  align="center">
     <input type=submit value="저장하기" >
     </td> 
</tr>

</table>
</form>

</div>
</body>
</html>

3. ExamController

package com.rubypaper.controller;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;

import javax.servlet.http.HttpServletRequest;

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.multipart.MultipartFile;

import com.rubypaper.exam.ExamServiceImpl;
import com.rubypaper.exam.ExamVO;

@Controller
public class ExamController {
	
	@Autowired   // 중요 - 클래스를 사용해야 한다.
 	private ExamServiceImpl  service;
    
	@RequestMapping("/form.do")
	String form(){	
		System.out.println("==> /form.do 확인");
		return "form";		
	}
	
	@RequestMapping("/formOk.do")
	String formOk(ExamVO vo){	
		service.insert(vo);
		return "redirect:getExamList.do";		
	}
	
	@RequestMapping("/form_psd.do")
	String form_psd(ExamVO vo){	
		System.out.println("==> /form_psd 확인");
		return "form_psd";		
	}
	
	@RequestMapping("/form_psd_ok.do")
	String form_psd_ok(ExamVO vo){	
		System.out.println("==> /form_psd_ok 확인");
		return "redirect:index.html";		
	}
	
	@RequestMapping("/getExamList.do")
	String getExamList(ExamVO vo , Model model ){	

		model.addAttribute("li", service.getExamList(vo));
		
		return "getExamList";		
	}
	
	@RequestMapping("/getExam.do")
	String getExam(ExamVO vo , Model model ){	
		model.addAttribute("m", service.getExam(vo));
		
		return "getExam";		
	}
}

4. index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<h2> 2022-10-13일 수업</h2>
<a href="form.do" > 저장하기 </a> <br><br>
<a href="getExamList.do" > 목록보기 </a> <br><br>
<a href="form_psd.do" > 자료실 저장 </a> <br><br>
</div>
</body>
</html>

 

'SpringBoot' 카테고리의 다른 글

myBatis2 (6)- 자료실(사진)  (0) 2022.10.13
myBatis2 (5)- 자료실(사진)  (0) 2022.10.13
myBatis2 (3)- 검색창  (0) 2022.10.13
myBatis2 (2)- 상세보기  (0) 2022.10.13
myBatis2 (1)  (0) 2022.10.13
Comments