메뉴 건너뛰기

2019.01.09 10:27

메모 상세 & EL

조회 수 824 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부




메모 리스트

메모 제목에 A 태그 달기


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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>
<%@ page import="memo.MemoDTO"%>
<!DOCTYPE  >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
 
    <%
    
        String path=request.getContextPath();
        //컨트롤러에서 넘어온 값을 읽어옴
        // request.getAttribute(key)
        //object 타입이라 형변환 해야함
        List<MemoDTO> items = (List<MemoDTO>) request.getAttribute("items");
    %>
 
    <table border="1">
        <tr>
            <th>번호</th>
            <th>이름</th>
            <th>메모</th>
            <th>날씨</th>
        </tr>
 
        <%
            for (MemoDTO dto : items) {
        %>
 
        <tr>
            <td><%=dto.getIdx()%></td>
            <td><%=dto.getWriter()%></td>
            
            
            
            <td>
            
            <a href="<%=path %>/memo_servlet/view.do?idx=<%=dto.getIdx() %>">
            <%=dto.getMemo()%></a>
            
            </td>
            <td><%=dto.getPost_date()%></td>
 
        </tr>
 
 
        <%
            }
        %>
    </table>
 
</body>
</html>
 
cs




2컨트롤러


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
else if(url.indexOf("view.do")!=-1){
            
            //string 값으로 넘어온다.
            //글번호
            int idx=Integer.parseInt(request.getParameter("idx"));
            
            //dao에 레코드 정보 조회
            MemoDTO dto=dao.MemoView(idx);
            
            request.setAttribute("dto", dto);
            
            String page = "/memo/view.jsp";
            
            RequestDispatcher rd=request.getRequestDispatcher(page);
            
            rd.forward(request, response);
            
        }
        
    }
 
cs



3 다오


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
// 게시글 상세
    public MemoDTO MemoView(int idx) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        MemoDTO dto = new MemoDTO();
 
        try {
            conn = DB.dbConn();
 
            String sql = "select * from memo where idx=?";
 
            pstmt = conn.prepareStatement(sql);
            pstmt.setInt(1, idx);
            rs = pstmt.executeQuery();
 
            if (rs.next()) {
 
                dto.setIdx(rs.getInt("idx"));
                dto.setMemo(rs.getString("memo"));
                dto.setWriter(rs.getString("writer"));
                dto.setPost_date(rs.getString("post_date"));
 
            }
 
        } catch (Exception e) {
 
        } finally {// resultset= > statement=> connection
 
            try {
                if (rs != null) {
                    rs.close();
                }
 
            } catch (Exception e2) {
                e2.printStackTrace();
            }
 
            try {
                if (pstmt != null) {
                    pstmt.close();
                }
 
            } catch (Exception e2) {
                e2.printStackTrace();
            }
 
            try {
                if (conn != null) {
                    conn.close();
                }
 
            } catch (Exception e2) {
                e2.printStackTrace();
            }
 
        }
 
        return dto;
    }
cs


4. 





4. 상세 페이지


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
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE  >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
 
 
<form name="form1" method="post">
 
    <table border="1">
    
        <tr>
            <td>날짜</td>
            <td>${dto.post_date}</td>
        </tr>
    
    <tr>
            <td>이름</td>
            <td><input name="writer" vlaue="${dto.writer}"> </td>
        </tr>
        <tr>
            <td>메모</td>
            <td><textarea name="memo"> ${dto.memo} </textarea></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
            <input type="button" value="수정" id="btnUpdate">
            <input type="button" value="삭제" id="btnDelete">
            </td>
        </tr>
    
    
    </table>
 
</form>
 
</body>
</html>
cs


  1. No Image 25Mar
    by
    2021/03/25 Views 139 

    jsp에서 멤버변수의 사용

  2. No Image 25Mar
    by
    2021/03/25 Views 147 

    패키지 컴파일 방법

  3. No Image 25Mar
    by
    2021/03/25 Views 108 

    jsp 소스 맨 위에 붙이는 기본 코드들

  4. No Image 25Mar
    by
    2021/03/25 Views 94 

    doc 문서 생성 및 패키지 압축 방법

  5. No Image 25Mar
    by
    2021/03/25 Views 117 

    패키지 생성 bat문

  6. No Image 25Mar
    by
    2021/03/25 Views 376 

    jsp:include 태그에서 파라미터사용시 오류

  7. No Image 16Jan
    by
    2019/01/16 Views 877 

    Get 방식과 Post 방식

  8. No Image 09Jan
    by
    2019/01/09 Views 957 

    각종 체크 &우편번호

  9. No Image 09Jan
    by
    2019/01/09 Views 895 

    아이디 체크

  10. No Image 09Jan
    by
    2019/01/09 Views 918 

    회원가입

  11. No Image 09Jan
    by
    2019/01/09 Views 1247 

    로그인 & AJAX 비동기 방식으로 처리&암호화&정규표현식

  12. No Image 09Jan
    by
    2019/01/09 Views 1075 

    수정 삭제

  13. filter 필터 &한글처리

  14. 09Jan
    by 조쉬
    2019/01/09 Views 824 

    메모 상세 & EL

  15. 한줄메모 삽입 & AJAX

  16. JDBC&데이터 처리 순서&DB CONN 따로 분리

  17. 태그문자&공백문자&줄바꿈 문자 처리

  18. 한줄메모 목록 리스트 AJAX

  19. No Image 09Jan
    by
    2019/01/09 Views 1405 

    MVC 패턴 & 도서 목록 컨트롤러에서 해당 URL 받아서 처리하기

  20. DBCP 커넥션 풀

Board Pagination Prev 1 2 3 4 Next
/ 4

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved