node.js 게시판 본문내용 줄바꿈 어떻게 하나요?

조회수 2648회
router.get('/read/:no',function(req,res,next) {
    var no = req.params.no;
    pool.getConnection(function(err,connection) {
        var sql = "select no, userID, title, contents, counts, date_format(date,'%Y-%m-%d %H:%i:%s') date, views from board where no=?";
        connection.query(sql,[no], function(err,board) {
            if(err) {
              console.error(err);
            }
            console.log("1개 글 조회 결과 확인 : ",board);
            var comment_sql = "select no, comment, commentEmail, date_format(date,'%Y-%m-%d %H:%i:%s') date from comment where boardNo=?";
            connection.query(comment_sql,[no], function(err,comments) {
                if(err) {
                  console.error(err);
                }
                console.log("리플 조회 결과 확인 : ",comments);
                res.render('read', {title:"글 조회", row:board[0], comments : comments})
                connection.release();
            });
        });
    });
});


<!DOCTYPE html>
<html>
<head>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css'/>
    <!-- 합쳐지고 최소화된 최신 CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

    <!-- 부가적인 테마 -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

    <!-- 합쳐지고 최소화된 최신 자바스크립트 -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body>
  <form action="/board/update" method="get">
      <table border="1" class="table">
          <input type="hidden" name="no" value="<%=row.no%>"/>
          <tr>
            <th>작성자</th>
            <th name="userID"><%=row.userID%></th>
          </tr>
          <tr>
            <td>제목</td>
            <td name="title"><%=row.title%></td>
          </tr>
          <tr>
            <td>변경일</td>
            <td name="date"><%=row.date%></td>
          </tr>
          <tr>
            <td>조회수</td>
            <td name="views"><%=row.views%></td>
          </tr>
          <tr>
            <td colspan="2" name="contents"><%=row.contents%></td>
          </tr>
          <tr>
              <td colspan="2">
                  <button type="submit" class="btn btn-primary">글 수정</button>
                  <button type="button" class="btn btn-default" onclick="location.href='/board'">목록으로</button>
              </td>
          </tr>
      </table>
  </form><br/><br/>

  <form method="post">
      <input type="hidden" name="counts" value="<%=row.counts%>"/>
      <div class="form-group">
          <label>Email</label>
          <input type="text" class="form-control" id="commentEmail" name="commentEmail" placeholder="이메일을 입력하세요">
      </div>
      <div class="form-group">
          <label>Password</label>
          <input type="password" class="form-control" id="commentPasswd" name="commentPasswd" placeholder="비밀번호를 입력하세요">
      </div>
      <label>Comment</label>
      <textarea class="form-control" rows="4" id="comment" name="comment" placeholder="내용을 입력하세요"></textarea>
      <input type="submit" value="확인" class="btn btn-default">
  </form><br/><br/><br/>

    <%
      for(var i = 0; i < comments.length; i++) {
        var oneItem = comments[i];
    %>
    <table class="table">
        <tr>
          <th>Email</th>
          <th><%=oneItem.commentEmail%></th>
          <th>Date</th>
          <th><%=oneItem.date%></th>
        </tr>
        <tr>
          <td colspan="5"><%=oneItem.comment%></td>
        </tr>
    </table>
    <% } %>

</body>
</html>

위에가 nodejs코드고 아래가 html코드 입니다 게시판 본문내용 출력 페이지 코드인데 본문내용 줄바꿈 출력이 안되요 db는 mysql쓰고 있구요. 해결방안 없을까요?

  • (•́ ✖ •̀)
    알 수 없는 사용자
  • 줄바꿈을 하시려면 css를 사용하시는게 더 편리해보입니다. td의 max-width를 제한해보세요. 알 수 없는 사용자 2018.4.13 01:00

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)