본문 바로가기
수업내용

20230609 수업내용🤣🤣🤣

by titlejjk 2023. 6. 9.

마저 하겠다~~~~~~~~~~~~~~~~~~~~~~~~~

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>/cafe/private/insertform.jsp</title>
</head>
<body>
	<div class="container">
		<h1>새글 작성 양식</h1>
		<form action="insert.jsp" method = "post">
			<div>
				<label for="title">제목</label>
				<input type="text" name = "title" id = "title"/>
			</div>
			<div>
				<label for = "content">내용</label>
				<textarea name="content" id="content" cols="30" rows="10"></textarea>
			</div>
			<button type = "submit">저장</button>
		</form>
	</div>
</body>
</html>

기존에 만들어둔 loginfilter로 가서 로그인한사람에게만 글을 쓸 수 있도록 filter를 걸어준다.

"/cafe/private/*"

요기까지 해준 후에 dao와 dto를 만든다.

먼저 CafeDto👉생성자와 setter getter까지 만들어 주었다.

package test.cafe.dto;

public class CafeDto {
	private int num;
	private String writer;
	private String title;
	private String content;
	private int viewCount;
	private String regdate;
	
	//생성자
	public CafeDto() {}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public String getWriter() {
		return writer;
	}

	public void setWriter(String writer) {
		this.writer = writer;
	}

	public String getTitle() {
		return title;
	}

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

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getViewCount() {
		return viewCount;
	}

	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}

	public String getRegdate() {
		return regdate;
	}

	public void setRegdate(String regdate) {
		this.regdate = regdate;
	}
	
}

하고 나머지는 주말까지 해오라는 숙제로..

/cafe/list.jsp
/cafe/detail.jsp
/cafe/private/insertform.jsp
/cafe/private/insert.jsp
/cafe/private/updateform.jsp
/cafe/private/update.jsp
/cafe/private/delete.jsp
만들기

-tip CafeDao를 미리 완성해 놓고 작업하면 편리하다.
public boolean insert(CafeDto dto){}
public booleanupdate(CafeDto dto){}
public booleandelete(int num){}
public booleanCafeDto getData(int num){}
public List<CafeDto>getList(){}
public boolean addViewCount(int num){} //글 조회수를 올리는 메소드

댓글