관리 메뉴

Road to 개발자

2021.03.06 계획 본문

계획/개발 일기

2021.03.06 계획

개발자가 되고싶은 개발자 2021. 3. 7. 01:48

개강 후 첫주말입니다. 오늘부터 매일 아침마다 계획을 세우려고 합니다.

 

"Show me your friends then I will show your future"

- Dan Peña -

 

youtu.be/sqhOlNCn1b4

 

 


계획 List

● 프로그래밍
- Review 다중 파일(이미지) 업로드 (JavaScript) 
- ReviewController  JSP부분 (Controller) 

- Product-page 상품 추가 JavaScript 문제 X
- 카트(장바구니) 부분 X
- var let const 공부 후 변경 (ex. product-page)  


● 블로그
- 계획  

● 자격증
- 세부 계획 일정 세우기 X





● Review 다중 파일(이미지) 업로드 (JavaScript)

 

파일 목록 : fileList = []

파일 목록 객체 : fileObject = {}

count = 0

 

1. 파일 업로드 시 filObject에 파일 정보와 고유 count를 넣어주고 fileList에 push 해준다. + DOM에도 고유 count 추가

2. 삭제 buttonDOM을 클릭할 시 DOM을 삭제하고 for문으로 filLIst 고유 count와 DOM 고유 count가 같은 fileList를 삭제해준다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img{
            width: 100px;
            height: 100px;
            margin-right: 10px;
 
            display: flex;
            box-sizing: border-box;
        }
        #cancelBtn{
            width: 100px;
            height: 100px;
 
            display: flex;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
 
<form action="" enctype="multipart/form-data"></form>
 
<div class="imgList">
 
</div>
<input type="file" multiple="multiple"/>
 
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>    
<script>
    const inputEl = document.querySelector('input')
 
    const fileList = []
    let count = 0;
 
    inputEl.addEventListener('change', (e) => {
 
        for(let i = 0; i<e.target.files.length; i++){
            const fileObject = {}
            
            fileObject.file = e.target.files[i]
            fileObject.number = count
 
            fileList.push(fileObject)
            
            var blobUrl = URL.createObjectURL(e.target.files[i])
            
            const buttonDOM = document.createElement('button')
            buttonDOM.className = "cancel" + count
            buttonDOM.dataset.number = count
            
            buttonDOM.id = "btnDOM"
 
            document.querySelector('.imgList').appendChild(buttonDOM)
 
            const imgDOM = document.createElement('img')
            imgDOM.className = "img"
            imgDOM.src = blobUrl
 
            document.querySelector('.cancel' + count).appendChild(imgDOM)
            
            const imgListEl = document.querySelector(".imgList")
 
 
 
            buttonDOM.addEventListener('click', (e) => {
 
                console.log('.candel' + count, "삭제")
                imgListEl.removeChild(buttonDOM)
                
                let buttonDomNumber = buttonDOM.dataset.number
 
                console.log(buttonDomNumber)
 
                for(let j=0; j < fileList.length; j++){
                    
                    if(fileList[j].number == buttonDomNumber){
                        fileList.splice(j, 1)
                    }
                }
                console.log(fileList)
 
            })            
 
            count++
        }
 
       
       console.log("count : ", count)
    })
 
</script>
</body>
</html>
cs

 


 

● ReviewController  JSP부분 (Controller)

 

DB에러때문에 완성을 못해서 해결해야됨.

 

 

 

이번에는 다른 에러가 발생한다. entityManagerFactory 관한 에러같은데 원인을 찾지 못했다.

 

에러를 읽어보니 Order Entity 에 @OneToMany 부분때문에 생긴 문제였다.

 

.

 

자바스크립트 ajax를 이용해 다중 파일을 Controller로 보내기 위해서 MultipartHttpServletRequest 를 사용하지 않고 예전 방법으로 ajax에서 보내준 파일 List를 한개씩 Part file 로 처리하려고 했으나 ajax로 보내는 과정에서 문제가 발생했고 문제를 찾지 못했다.

 

보류

 


 

 

 

'계획 > 개발 일기' 카테고리의 다른 글

2021.03.18 계획  (0) 2021.03.18
2021.03.07 계획  (0) 2021.03.08
2021.03.04 계획  (0) 2021.03.05
2021.03.03 계획  (0) 2021.03.03
2021.03.02 계획  (0) 2021.03.03