当我搜索特定单词时,仅将首页分类。它在首页上很好地显示页面和帖子。

但是当我转到第2页或下一页时,seaching关键字不适用于
这是地址问题吗?

我猜这是sql或Paging.java问题,因为当我在BDAO打印页面日志时,它显示的页面很好,我单击了。

我也不知道该如何转让keyWord&keyField ..!

我使用oracle DB。

  <%
String keyWord = (String)request.getParameter("keyWord");
String keyField = (String)request.getParameter("keyField");
%>
<script>

    function searchCheck(frm){
        //검색
        if(frm.keyWord.value ==""){
            alert("검색 단어를 입력하세요.");
            frm.keyWord.focus();
            return;
        }
        frm.submit();
    }

    function PageMove(page){
         var keyWord = '<%=keyWord%>'
         var keyField = '<%=keyField%>'
         console.log(keyWord);
         if(keyWord !=''){
        location.href = "list.do?page="+page+"&keyWord=" + keyWord + "&keyField=" + keyField;
         }
         location.href = "list.do?page="+page;
      }
</script>
</head>
<body>

    <table width="800" cellpadding="0" cellspacing="0" border="1">
        <tr>
            <td>번호</td>
            <td>이름</td>
            <td>제목</td>
            <td>날짜</td>
            <td>히트</td>
        </tr>
        <c:forEach items="${list}" var="dto">
        <tr>
            <td>${dto.bId}</td>
            <td>${dto.bName}</td>
            <td>
                <c:forEach begin="1" end="${dto.bIndent}">-</c:forEach>
                <a href="content_view.do?bId=${dto.bId}">${dto.bTitle}</a></td>
            <td>${dto.bDate}</td>
            <td>${dto.bHit}</td>
        </tr>
        </c:forEach>
        <tr>
            <td colspan="5">
                <form action="list.do" method="post" name="search">
                <select name="keyField">
                    <option value="bTitle">글 제목</option>
                    <option value="bContent">글 내용</option>
                    <option value="bName">작성자</option>
                </select>
                <input type="text" name="keyWord">
                <input type="button" value="검색" onclick="searchCheck(form)">
                </form>
            </td>
        </tr>


        <tr>
            <td colspan="5"> <a href="write_view.do">글작성</a> </td>
        </tr>
    </table>

    <div class="toolbar-bottom">
  <div class="toolbar mt-lg">
    <div class="sorter">
      <ul class="pagination">
        <li><a href="javascript:PageMove(${paging.firstPageNo})">맨앞으로</a></li>
        <li><a href="javascript:PageMove(${paging.prevPageNo})">앞으로</a></li>
              <c:forEach var="i" begin="${paging.startPageNo}" end="${paging.endPageNo}" step="1">
                  <c:choose>
                      <c:when test="${i eq paging.pageNo}">
                <li class="active"><a href="javascript:PageMove(${i})">${i}</a></li>
                      </c:when>
                      <c:otherwise>
                        <li><a href="javascript:PageMove(${i})">${i}</a></li>
                      </c:otherwise>
                  </c:choose>
              </c:forEach>
        <li><a href="javascript:PageMove(${paging.nextPageNo})">뒤로</a></li>
        <li><a href="javascript:PageMove(${paging.finalPageNo})">맨뒤로</a></li>
      </ul>
    </div>
  </div>
</div>

最佳答案

当您调用pageMove()时,您似乎从未传递关键字或键字段。您最好在函数中查找它们的值,而不是将它们作为参数:

function PageMove(page){
    var keyWord = document.getElementById("keyWord").value;
    var keyField = document.getElementById("keyField").value;
    location.href = "list.do?page=" + page + "&keyWord=" + keyWord + "&keyField=" + keyField;
}

关于java - 当我转到下一页搜索关键字时,jsp分页问题不适用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52847297/

10-10 01:08