728x90

 

배열과 달리 객체배열은 vo class의 toString 메소드나 오버라이딩이 안되어있더라도 str 찍는 메소드를 이용하면

안에 값을 찍을 수 있는데

이 부분이 제대로 숙지가 된 듯함

보지 않고 바로 코딩 성공

 

선언부터 할당, 초기화, 삭제, 출력까지 머릿 속에 잘 들어온 듯

이제 다른거 연습하러 가야겠다 가끔씩 기억 리커버리를 위해 한번씩 해주는 걸로

 

/******************************** Object Array practice 4th ***************************************/	

		//객체배열
		//
		// 배열 선언 : Stack 영역에 공간 생성(변수의 선언 : stack에 공간 차지)
		// 배열 할당 : heap 영역에 공간 생성
		// 배열 초기화 : 인덱스,중괄호,for문
		// 배열 삭제 : null
		// 배열 값 출력하는 방법 2가지 : for문 + vo클래스 toString메소드
		
		// 객체배열 선언
		Person[] objArr010;

		// 객체배열 선언&할당
		Person[] objArr011 = new Person[2];
		Person[] objArr013 = new Person[3];
		
		// 객체배열 초기화
		// 		방법1 : 인덱스
		objArr011[0] = new Person("김기기",22,'M',171,66);
		objArr011[1] = new Person("최치치",22,'M',171,67);
				
		
		// 		방법2 : 중괄화
		Person objArr012[] = {new Person("박비비",23,'M',182,67),
							  new Person("최치치",22,'M',171,67),
							  new Person("김기기",22,'M',171,66)
							};
		// 		방법3 : for문
		for(int i=0; i < objArr013.length; i++) {
			objArr013[i] = new Person("김기기",22,'M',171,66);
			System.out.println("for문 초기화 = "+objArr013[i].personInfo());
		}
			
			
			
		// 객체배열  삭제
		objArr013 = null;
		
		// 객체 배열 내 값 출력
		// 방법1 : for문
		// 방법2 : Arrays.toString
		System.out.println(Arrays.toString(objArr013));
		// 인덱스+toString(vo class)
		
		System.out.println(objArr012[0].personInfo());

 

 

728x90
반응형
728x90

 

시간도 배로 걸렸지만 오늘은 코딩하면서 좀 이해가 많이 된 것 같다.

 

내용에서 줄바꿈 개행문자를 바꾸는 pageContext.setattribute와 ${ fn:replace(바꿀범위, 바꿀 문자, 대체할 문자)} 부분의 이해가 머리 속에 들어왔고,

첨부파일 부분은 거의 한방에 쓸 수 있었던 것 같다. 오리지널이랑 리네임이 들어가는 부분이 좀 헷갈림

아직 댓글창 부분이랑 스크립트 아래 부분이 잘 이해 안되는게 많은데

그래도 제이쿼리 변수 선언하는 것과 왜 해당 변수들을 선언해서 썼는지 의도 파악이 되었다

data[i]부분을 for in문 돌려서 한 부분이 살짝 이해가 좀 안가는 부분이 있었는데 

댓글을 불러들이기 위한거라는 큰 틀은 이해했으니 ok

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>PRAC</title>

<style type="text/css">
	#boardDetailTable{width:800px; margin:auto; border-collapse:collapse; border-left:hidden;}
	#boardDetailTable tr td{padding: 5px;}
	.replyTable{margin: auto; width: 500px;} 
</style>

</head>
<body>

	<c:import url="../common/menubar.jsp"/>
	
	<h1 align="center">${board.boardId }번의 글 상세보기</h1>
	
	<form action="bupView.bo" method="post">
		<table border="1" id="boardDetailTable">
			<tr>
				<th>번호</th>
				<td>
					${board.boardId }
					<input type="hidden" name="boardId" value="${board.boardId }">
					<input type="hidden" name="page" value="${ page }">
				</td>
			</tr>
			<tr>
				<th>제목</th>
				<td>
					${ board.boardTitle }
					<input type="hidden" name="boardTitle" value="${board.boardTitle }">
				</td>
			</tr>
			<tr>
				<th>작성자</th>
				<td>
					${board.nickName }
					<input type="hidden" name="nickName" value="${ board.nickName }">
				</td>
			</tr>
			<tr>
				<th>작성날짜</th>
				<td>
					${board.boardCreateDate }
				</td>
			</tr>
			
			<tr>
				<th>내용</th>
				
				<% pageContext.setAttribute("newLineChar", "\r\n"); %>
				<td>
					${fn:replace(board.boardContent,newLineChar, "<br>") }
					<input type="hidden" name="boardContent" value="${ boardContent }">
				</td>
			</tr>
			
			
			<c:if test="${ !empty board.originalFileName }">
			<tr>
				<th>첨부파일</th>
				<td>
					<a href="${pageContext.servletContext.contextPath }/resources/buploadFiles/${ board.renameFileName }" download="${board.originalFilename }">${board.originalFileName }</a>
					<input type="hidden" name="originalFileName" value="${ board.originalFileName }">
					<input type="hidden" name="renameFileName" value="${board.renameFileName }">
				</td>
			</tr>
			</c:if>
			

			<!-- url 변수선언 -->
			<c:url var="bdelete" value="bdelete.bo">
				<c:param name="bId" value="${board.boardId }"/>
				<c:param name="renameFileName" value="${ board.renameFileName }"/>
			</c:url>
			<c:url var="blist" value="blist.bo">
				<c:param name="page" value="${ page }"/>
			</c:url>
			
			
			<!-- 로그인유저 수정삭제 버튼 보이기 -->
			<c:if test="${ loginUser.id eq board.boardWriter }">
			<tr>
				<td colspan="2" align="center">
					<button type="button">수정하기</button>
					<button type="button" onclick="location.href='${bdelete}'">삭제하기</button>
				</td>
			</tr>	
			</c:if>
	
		</table>
	</form>
	
	
	
	
	<!-- 시작페이지,목록보기 이동버튼 -->
	<p align="center">
		<button type="button" onclick="location.href='home.do'">시작페이지</button>
		<button type="button" onclick="location.href='${blist}'">목록보기</button>
	</p>



	
	<!-- 댓글창 -->
	<table class="replyTable">
		<tr>
			<td><textarea cols="55" rows="3" id="replyContent"></textarea></td>
			<td><button id="rSubmit">댓글 등록</button></td>
		</tr>
	</table>
	<table class="replyTable" id="rtb">
		<thead>
			<tr>
				<td colspan="2"><b id="rCount"></b></td>
			</tr>	
		</thead>
		<tbody>
			<!-- 쓴 댓글 보이는 부분 -->
		</tbody>
	</table>
	
	<script>
		// 댓글 등록 : jQuery ajax
		$('#rSubmit').click(function(){
			var rContent = $('#replyContent').val();
			var refBId = ${board.boardId};
			
			$.ajax({
				url:'addReply.bo',
				data:{replyContent:rContent, boardId:reBId},
				success:function(data){
					console.log(data);
					if(data == 'success'){
						$('#replyContent').val(' ');
					}
				},
				error:function(data){
					console.log(data);
				}
			});
		});
	
		// 등록한 댓글 읽어오기
		function getReplyList(){
			$.ajax({
				url:'rList.bo',
				data:{bId:${board.boardId}},
				success:function(data){
					console.log(data);
					
					$tableBody = $('#rtb tbody');
					$tableBody.html('');
					
					// 변수선언
					// var a; 자바스크립트 변수 // var $a; jQuery 변수
					var $tr;
					var $writer;
					var $content;
					var $date;
					$('#rCount').text('댓글('+data.length+')');
					
					if(data.length > 0){
						for(var i in data){
							$tr = $('<tr>');
							$writer = $('<td>').css('width','100px').text(data[i].nickName); 
							$content = $('<td>') .text(data[i].replyContent);
							$date = $('<td width="100px">').text(data[i].replyCreateDate);	
							
							$tr.append($writer);
							$tr.append($content);
							$tr.append($date);
							$tableBody.append($tr);
						}
					}else{
						$tr = $('<tr>');
						$content = $('<td colspan="3">').text('등록된 댓글이 없습니다.');
						
						$tr.append($content);
						$tableBody.append($tr);
					}
				},
				error:function(data){
					console.log(data);
				}
			});
		}
	
	
		// 다른 사람이 쓴 댓글도 볼 수 있게 5초마다 읽어오도록
		function(){
			getReplyList();
			
			setInterval(function(){
				getReplyList();
			}, 5000);
		});
	
	</script>



</body>
</html>
728x90
반응형
728x90

 

객체배열에서는 Arrays.toString을 해도 객체가 여러개라 안먹힌다는 점

그래서 인덱스 번호 하나씩 찍고 vo클래스의 toString 메소드로 출력해야 값이 나온다는 점 기억!

배열 안에 객체 넣는 부분도 꽤나 익숙해짐. 어버버하는 부분이 꽤 많이 줄었다

 

/******************************** Object Array practice 3rd ***************************************/	

		//객체배열
		//
		// 배열 선언 : Stack 영역에 공간 생성(변수의 선언 : stack에 공간 차지)
		// 배열 할당 : heap 영역에 공간 생성
		// 배열 초기화 : 인덱스,중괄호,for문
		// 배열 삭제 : null
		// 배열 값 출력하는 방법 2가지 : for문 + vo클래스 toString메소드
		
		// 객체배열 선언
		Person02[] oArr000;
		// 객체배열 할당
		Person02[] oArr001 = new Person02[3];
		Person02[] oArr003 = new Person02[3];
		
		// 초기화
		// 	방법1 : index
		oArr001[0] = new Person02("박",25,'M',161,65);
		oArr001[1] = new Person02("강",22,'F',161,45);
		oArr001[2] = new Person02("최",22,'F',161,45);
		
		// 	방법2 : 중괄호
		// 객체배열 선언,할당과 동시에 초기화
		Person02[] oArr002 = {new Person02("김",29,'M',171,62),
				new Person02("이",28,'M',192,83),
				new Person02("최",25,'M',185,81)
		};
		
		//  방법3 : for문
		for(int i=0; i < oArr003.length; i++) {
			oArr003[i] = new Person02("a",i+20,'M',i+170,i+60);
			System.out.println(Arrays.toString(oArr003));
		}
		
//		System.out.println(Arrays.toString(oArr003[1])); // error : toString // The method toString(long[]) in the type Arrays is not applicable for the arguments (Person02)
		System.out.println(oArr003[1].personInfo());
		
		for(int i=0; i < oArr003.length;i++) {
			System.out.println(oArr003[i]); // chap06_objectArray.model.vo.Person02@33909752
		}
	
		oArr003 = null;
		System.out.println(Arrays.toString(oArr003)); // null

		System.out.println(oArr001[0].personInfo()); 
		
		for(int i=0; i < oArr001.length; i++) {
			System.out.println(oArr001[i].personInfo()); 
		}
728x90
반응형
728x90

 

 

new 연산자 다음 vo클래스명 작성하고 그 다음 소괄호, 중괄호 같은 것들이 아직 헷갈리는 중

첫번째 할 때는 그냥 일반 배열에서의 초기화 3가지 방법에 대해 잘 적용하지 못했고 생각도 잘못했는데

2번째 되면서 방법2인 중괄호 방법도 적용 시키는데 성공하고 좀 틀이 잡힌 느낌

숙련도가 올라가는 느낌이 든다

 

/******************************** Object Array practice 2nd ***************************************/	
	
	public void objectArr02() {
		
		// 객체배열
		//
		// 배열 선언 : Stack 영역에 공간 생성(변수의 선언 : stack에 공간 차지)
		// 배열 할당 : heap 영역에 공간 생성
		// 배열 초기화 : 인덱스,중괄호,for문
		// 배열 삭제 : null
		// 배열 값 출력하는 방법 2가지 : for문 + vo클래스 toString메소드
		
		// 배열 선언
		Person[] oArr;
		
		// 배열 선언 & 할당
		Person[] obArr = new Person[3];
		
		// 배열 초기화
		// 	방법1 : index
		obArr[0] = new Person("킴",20,'M',173,69);		// 중괄호가 아닌 소괄호
		obArr[1] = new Person("choi", 22, 'M', 165,45);
		obArr[2] = new Person("yu",32,'M',173.2,72.3);
		
		// 	방법2 : 중괄호
		Person02[] obArrr000 = {new Person02(),
new Person02(),
new Person02()
								};
		
		
		// 	방법3 : for문
		Person02[] obArrr = new Person02[5];
		for(int i=0; i < obArrr.length; i++) {
			obArrr[i] = new Person02("a",1,'M',1,1);
			System.out.println(obArrr[i].personInfo()); // 객체값 출력
		}
		// 이중포문으로 객체 안 숫자 증가시켜보기
		for(int i=0; i < obArrr.length;i+=2) {
			int j=1;
			for(; j < obArrr.length; j++) {
				obArrr[i] = new Person02("a",j,'M',j+10,j+20);
				System.out.println(obArrr[i].personInfo());
			}
		}
		
		// 객체 배열 : 출력
		// 
		for(int i=0; i < obArrr.length; i++) {
			obArrr[i] = new Person02();
			System.out.println(obArrr[i] + " ");		// 주소값 출력
			System.out.println(obArrr[i].personInfo()); // 객체값 출력
		}
		
		System.out.println("====null====");
		System.out.println(Arrays.toString(obArrr)); // [chap06_objectArray.model.vo.Person02@6d06d69c, chap06_objectArray.model.vo.Person02@7852e922, chap06_objectArray.model.vo.Person02@4e25154f, chap06_objectArray.model.vo.Person02@70dea4e, chap06_objectArray.model.vo.Person02@5c647e05]
		System.out.println(obArrr[0].personInfo());  // null, 0,  0.0, 0.0
		obArrr = null;
		System.out.println(Arrays.toString(obArrr)); // null
		
		Person02[] objArr001;
		Person02[] objArr002 = new Person02[5];
		objArr002[0] = new Person02("a", 1,'M',171,66.2);
		objArr002[1] = new Person02();
		objArr002[2] = new Person02();
//		objArr002[2] = new Person02(Person02.getName()); // Person02클래스의 게터에서 값을 끌어올 수 있을까 해서 해봄 
		// 스태틱 요구함 Cannot make a static reference to the non-static method getName() from the type Person02
		Person02[] objArr004 = {new Person02(),
								new Person02("철희", 32, 'M', 171,56),
								new Person02("영희", 32, 'W', 161,46)
								};

		Person02[] objArr003 = new Person02[5];
		for(int i=0; i < objArr003.length; i++) {
			objArr003[i] = new Person02(); 
			System.out.println(objArr003[i].personInfo());
		}
		
	

	}
728x90
반응형
728x90

배열에 객체가 들어가다보니 기존 배열보다 좀 까다롭다는 느낌이 들었다

배열 안에 있는 객체 속성값에 접근해서 출력하는게 기존과는 달라서 좀 헤맸다는 것

기존 기본형 자료타입들과 다르게 객체타입이다보니 헷갈리는게 많았다는 것

아직은 숙련도가 많이 부족해서 계속 반복해서 내 손발처럼 될 수 있게 연습해야겠다

 

package chap06_objectArray.controller;

import java.util.Arrays;

import chap06_objectArray.model.vo.Person;

public class Person02Controller {
	
	public void objectArr00() {
		
		// 예제
		// 출처 :http://daplus.net/java-java%EB%A1%9C-%EA%B0%9D%EC%B2%B4-%EB%B0%B0%EC%97%B4-%EB%A7%8C%EB%93%A4%EA%B8%B0/
		
		// 1.선언 및 인스턴스화
		A[ ] arr = new A[4];
		
		// 2.객체 초기화
		// 방법1
		arr[0] = new A();
		arr[1] = new A();
		arr[2] = new A();
		arr[3] = new A();
		
		// 방법2
		for( int i=0; i<4; i++ ) {
			  arr[i] = new A();
		}
		// 방금 만든 객체에서 기존 메소드 호출 가능해짐
		// 방법1
		int x = arr[1].getNumber();
		// 방법2
		arr[1].setNumber(x);
		
	}
	
	public void objectArr01() {
		
		// 객체배열
		//
		// 배열 선언 : Stack 영역에 공간 생성(변수의 선언 : stack에 공간 차지)
		// 배열 할당 : heap 영역에 공간 생성
		// 배열 초기화 : 인덱스,중괄호,for문
		// 배열 삭제 : null
		// 배열 값 출력하는 방법 2가지 : for문 + vo클래스 toString메소드
		
		
		
		
		// 배열 선언 - stack 영역에 생성
		String objArr;
		
		// 배열 할당 - heap 영역에 생성
		Person[] objArr01 = new Person[3];
		
		// 초기화
		//	1)인덱스
		objArr01[0] = new Person();
		objArr01[1] = new Person("김철수", 20, 'M', 170.5, 70);
		objArr01[2] = new Person("이순신", 40,'M', 180.5, 85.5); 

// vo Person		
//		private String name;
//		private int age;
//		private char gender;
//		private double height;
//		private double weight;
		
		// 	2) 중괄호
		Person objArr02 = new Person("안중근", 30,'M', 175.5, 75.3);
		Person[] objArr03 = {new Person("유관순", 18,'F', 160.2, 45.5),
							 new Person("신사임당", 40,'F', 157.5, 43.2),
							 new Person("세종대왕", 55, 'M', 180.5, 80.5)
							};
		System.out.println(objArr02); // chap06_objectArray.model.vo.Person@6d06d69c
		System.out.println(Arrays.toString(objArr03)); // 객체주소값 출력 : [chap06_objectArray.model.vo.Person@6d06d69c, chap06_objectArray.model.vo.Person@7852e922, chap06_objectArray.model.vo.Person@4e25154f]

//		System.out.println(Arrays.toString(objArr02[0])); // The type of the expression must be an array type but it resolved to Person
//		for(int i=0; i < objArr02.length; i++) { // 
//			System.out.println(objArr02[i]);	// The type of the expression must be an array type but it resolved to Person
//		}										// for문 출력은 int나 int로 자동형변환되는 소수들이 가능
		
		
		// 	3) for문
		Person[] objArr04 = new Person[3];
		for(int i=0; i < objArr04.length; i++) {
			objArr04[i] = 
		}
		
		
		// 객체 주소값 출력
		for(int i=0; i < objArr03.length; i++) {
			System.out.println("objArr03 = "+objArr03[i]);
//				objArr03 = chap06_objectArray.model.vo.Person@7852e922
//				objArr03 = chap06_objectArray.model.vo.Person@4e25154f
//				objArr03 = chap06_objectArray.model.vo.Person@70dea4e
		}
		// vo클래스 toString()을 이용한 객체속성값 출력
		for(int i=0; i < objArr03.length; i++) {
			System.out.println(objArr03[i].personInfo());
//				유관순, 18, F, 160.2, 45.5
//				신사임당, 40, F, 157.5, 43.2
//				세종대왕, 55, M, 180.5, 80.5
		}
//		System.out.println(Arrays.toString(objArr03.personInfo())); // Cannot invoke personInfo() on the array type Person[]
//		System.out.println(Arrays.toString(objArr03[0].personInfo())); // The method toString(long[]) in the type Arrays is not applicable for the arguments (String)
//		System.out.println(Arrays.personInfo()); // toString빼고 바로 출력할려했으나 에러 : The method personInfo() is undefined for the type Arrays
		
		// 삭제
		objArr03 = null;
		System.out.println(objArr03); // null
		System.out.println(Arrays.toString(objArr03)); // null
		for(int i=0; i < objArr03.length; i++) {
			System.out.println(objArr03[i].personInfo()); // Exception in thread "main" java.lang.NullPointerException
		}
		
		
	}
	
	
	
}
728x90
반응형
728x90

 

boardDetailView

3rd times

3번째 반복 연습

머리에 박아두기!!

 

유레카

삭제 할려고 콘트롤러에 데이터 보낼 때, 삭제할 게시물 번호 외에도 해당 게시물에 파일이 있다면

파일명 데이터도 같이 보내야한다

즉 삭제할 게시물 번호와 해당 게시물 안에 있는 파일명을 컨트롤러로 보내줘야함

 

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

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>prac</title>

<style type="text/css">
	#boardDetailTable{ width:800px; margin:auto; border-collapse:collapse; border-left:hidden; border-right:hidden;}
	#boardDetailTable tr td{ padding: 5px;}
	.replyTable{margin: auto; width:500px;}
</style>

</head>
<body>

	<c:import url="../common/menubar.jsp"/>
	
	<h1 align="center">${board.boradId }번 글의 상세보기</h1>
	
	
	<form action="" method="post">
		<table>
			<tr>
				<th>번호</th>
				<td>
					<input type="hidden" name="boardId" value="${ board.boardId }">
					<input type="hidden" name="page" value="${ page }">
				</td>
			</tr>
			
			<tr>
				<th>제목</th>
				<td>
					${ board.boardTitle }
					<input type="hidden" name="boardTitle" value="${ board.boardTitle }">
				</td>
			</tr>
			
			<tr>
				<th>작성자</th>
				<td>
					${ board.nickName }
					<input type="hidden" name="nickName" value="${ board.nickName }">
				</td>
			</tr>		
			<tr>
				<th>작성날짜</th>
				<td>
					${ board.board CreateDate }
				</td>
			</tr>		
			<tr>
				<th>내용</th>
				<% pageContext.setAttribute("newLineChar", "\r\n"); %>
				<td>
					${fn:replace(board.boardContent, newLineChar, "<br>" }
					<input type="hidden" value="${ board.boardContent }" name="boardContent">
				</td>
				
			</tr>	
			
			<c:if test="${board.originalFileName != null }">	
				<tr>
					<th>첨부파일</th>
					<td>
						<a href="${pageContext.servletContext.contextPath }/resources/buploadFiles/${board.renameFileName}" download="${board.originalFileName }"> ${board.originalFileName }</a>
						<input type="hidden" name="renameFileName" value="${ board.renameFileName }">
						<input type="hidden" name="originalFileName" vlaue="${ board.originalFileName }">
					</td>
				</tr>
			</c:if>
			
			<!-- url변수선언 -->
			<c:url var="bdelete" value="bdelete.bo">
				<c:param name="bId" value="${ board.boardId }"/>
				<c:param name="renameFileName" value="${ board.renameFileName }"/>
			</c:url>
			<c:url var="blist" value="blist.bo">
				<c:param name="page" value="${ page }"/>
			</c:url>
			
			<!-- 로그인한 유저가 작성자라면, 수정삭제버튼 보이기 --> 
			<c:if test="${ loginUser.id eq ${ board.boardWriter }">
				<tr>
					<td colspan="2" align="center">
						<button type="button" onclick="locaiont.href='${ bupdate }'">수정하기</button>
						<button type="button" onclick="location.href='${ bdelete }'">삭제하기</button>
					</td>	
				</tr>
			</c:if>
			
			
		</table>
	</form>
	

</body>
</html>
728x90
반응형
728x90

 

jstl의 <c:url>과 <c:param>으로

변수 만들어서 버튼 태그 온클릭에 <c:url>에서 선언한 변수를 집어 넣고

해당 url로 이동하고 필요한 데이터를 name속성에 같이 보냄

 

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

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>prac</title>

<style type="text/css">
	#boardDetailTable{ width:800px; margin:auto; border-collapse:collapse; border-left:hidden; border-right:hidden;}
	#boardDetailTable tr td{ padding: 5px;}
	.replyTable{margin: auto; width:500px;}
</style>

</head>
<body>

	<c:import url="../common/menubar.jsp"/>
	
	<h1 align="center">${board.boradId }번 글의 상세보기</h1>
	<form action="bupview.bo" method="post">
		<table>
			<tr>
				<th>번호</th>
				<td>
					${ board.boardId }
					<input type="hidden" value="${ board.boardId }" name="boardId">
					<input type="hidden" value="${ page }" name="page">
				</td>
			</tr>
				<th>제목</th>
				<td>
					${board.boardTitle}
					<input type="hidden" value="${ board.boardTitle }" name="boardTitle">
				</td>			
			<tr>
				<th>작성자</th>
				<td>
					${ board.nickName }
					<input type="hidden" value="${ board.nickName }" name="nickName">
				</td>
			</tr>
			<tr>
				<th>작성날짜</th>
				<td>
					${ board.boardCreateDate }
					<input type="hidden" value="${ board.boardCreateDate }" name="boardCreateDate">
				</td>
			</tr>
			<tr>
				<th>내용</th>
				<% pageContext.setAttribute("newLineChar", "\r\n"); %>
				<td>
					${ fn:replace(board.boardContent, newLineChar, "<br>") }
					<input type="hidden" value="${ board.boardContent }" name="boardContent">
				</td>
			</tr>
			
			<c:if test="${ !empty originalFileName }">
				<tr>
					<th>첨부파일</th>
					<td>
						<a href="${pageContext.servletContext.contextPath }/resoures/buploadFiles/${board.renameFileName}" download="${board.originalFileName }">${board.originalFileName}</a>
						<input type="hidden" value="${ board.originalFileName }" name="originalFileName">
						<input type="hidden" value="${ board.renameFileName }" name="board.renameFileName">
					</td>
				</tr>
			</c:if>
			
			<c:url var="bdelete" value="bdelete.bo">	<!-- c:url 변수선언함. 그리고 아래 button태그에서 끌어다 씀 -->
				 <c:param name="bId" value="${ board.boardId }"/>	<!-- 삭제버튼에 필요한 게시판번호 데이터보내기 -->
				 <c:param name="renameFileName" value="${ board.renameFileName }"/>
			</c:url>
			<c:url var="blist" value="blist.bo">  <!-- 게시판목록으로 가는 url설정 -->
				<c:param name="page" value="${ page }"/> <!-- 보던 게시판으로 돌아가기 위해 page번호 필요 for pagination -->
			</c:url>		
			
			<c:if test="${ loginUser.id eq board.boardWriter }">
				<tr>
					<td colspan="2" align="center">
						<button type="button" onclick="location.href=''">수정하기</button>
						<button type="button" onclick="location.href='${bdelete}'">삭제하기</button>
					</td>
				</tr>
			</c:if>
			
		</table>
	</form>
	
	
	
	<p align="center">
		<button onclick="location.href='home.do'">시작 페이지 이동</button>
		<button onclick="location.href='${ blist }'">목록 보기로 이동</button>
	</p>



</body>
</html>
728x90
반응형
728x90

 

1. 브랜치(branch) 생성 : branch

$ git branch 브랜치명

예시

$ git branch test1

2.브랜치(branch) 변경 : checkout

$ git checkout 브랜치명

 

 ※ 브랜치(branch) 생성 및 변경 한번에

-b 추가

$ git checkout **-b** 브랜치명

3.Merge

$ git **merge** <commit>

 

4. 브랜치(branch) 삭제 : branch -d

$ git **branch -d** 브랜치명

 

 

 

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository
$ git init
Initialized empty Git repository in D:/Git_Repository/.git/

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -b test1
error: unknown switch `b'
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]
   or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]
   or: git branch [<options>] [-l] [<pattern>...]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track[=(direct|inherit)]
                          set branch tracking configuration
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display object names

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    -l, --list            list branch names
    --show-current        show current branch name
    --create-reflog       create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --recurse-submodules  recurse through submodules
    --format <format>     format to use for the output


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch master
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test1
error: pathspec 'test1' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch a
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ ls -al
total 20
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:18 ./
drwxr-xr-x 1 csy62 197609 0 Jul 14 08:20 ../
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:17 .git/
-rw-r--r-- 1 csy62 197609 0 Jul 31 03:18 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch 'test'
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        a.txt

nothing added to commit but untracked files present (use "git add" to track)

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git add a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
[master (root-commit) 0505a6a] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -m test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test
* test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git branch -m test0

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch
* test0
  test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch -d test2
Deleted branch test2 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
On branch test2
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test2
error: Cannot delete branch 'test2' checked out at 'D:/Git_Repository'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout -b test3
Switched to a new branch 'test3'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test3)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test3
Deleted branch test3 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test2
Already on 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 76d033f] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test3
merge: test3 - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge master
merge: master - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git show
commit 76d033f78943e8d9856b60b2c323dd80098a23fe (HEAD -> test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:30:07 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git status
On branch test2
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 c0f83ba] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge
fatal: No remote for the current branch.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git test1
git: 'test1' is not a git command. See 'git --help'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating 0505a6a..c0f83ba
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 "a - \353\263\265\354\202\254\353\263\270.txt"                            | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git status
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git show
commit c0f83baab10cff7a90120db6ba4f3975c3e743f7 (HEAD -> test1, test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:32:43 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 2
[test2 d4529f8] 2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git commit -m 3
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test3
error: pathspec 'test3' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
error: The branch 'test2' is not fully merged.
If you are sure you want to delete it, run 'git branch -D test2'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating c0f83ba..d4529f8
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
Deleted branch test2 (was d4529f8).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
728x90
반응형
728x90

 

이벤트 추가 : addEventListener
이벤트 삭제 : removeEventListener

 

addEventListener(연결이벤트, 실행할 함수)
 
 
마우스가 버튼에 올라가면 올라갔다고 콘솔로그 뜨고 클릭하면 클릭했다고 뜨고
클릭 후 이벤트가 삭제되면서 mouseover만 작동하고 click은 지우는 js코드 연습
 
 
    <h3>addEventListener</h3>
    <div id="first" class="div0"></div>
    <button id="do1">do1 확인</button>
    <button id="do2">do2 확인</button>
    <script>
        var do1 = document.getElementById('do1');
        var do2 = document.getElementById('do2');
        // var div0 = document.getElementByClass('div0');

        function dodo1_1(){
            console.log("click");
        }
        function dodo1_2(){
            console.log("in");
        }   
        function div0_1(){
            console.log("dvi0");
            div0.innerText = "hi";

        }

        do1.addEventListener('click',dodo1_1);
        do1.addEventListener('mouseover',dodo1_2);

        do2.addEventListener('click',function(){
            console.log('do2 실행. 제거하기');
            do1.removeEventListener('click',dodo1_1);

        // div0.addEventListener('click',div0_1);

        })

    </script>
728x90
반응형
728x90

 

OOP 공부하면서 캡슐화 개념 이해 + 입출금 잔액조회

코드 해보기!

머릿 속에 다른 클래스의 인자에서 해당 클래스의 매개변수로 데이터 넣기가 포인트 찍힘

 

 

package chap05_OOP.A_encapsulation;

public class Run {

	public static void main(String[] args) {

		
		Encapsulation01 encap = new Encapsulation01();
		encap.deposit(100);
		encap.withdraw(50);
		encap.withdraw(150);
		encap.checkBalance();
	}

}

 

728x90
반응형

+ Recent posts