我收到此错误。但似乎很好地获得了“ keyField”。因为它显示bTitle!
list.do:29 Uncaught ReferenceError: bTitle is not defined
at PageMove (list.do:29)
at <anonymous>:1:1
当我搜索特定单词时,它会在首页上很好地显示页面和帖子。
但是当我转到第2页或下一页时,seaching关键字不适用,也无法移至下一页。
,但仍然无法移至下一页。这是地址问题吗?
这是我的代码!
<%
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 && keyField){
location.href = "list.do?page="+page+"&keyWord=" + keyWord + "&keyField=" + keyField;
}
location.href = "list.do?page="+page;
}
</script>
<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)">
<%-- <input type="hidden" value="${keyWord}">
<input type="hidden" value="${keyField}"> --%>
</form>
</td>
</tr>
<tr>
<td colspan="5"> <a href="write_view.do">글작성</a> </td>
</tr>
</table>
<%=PageAction.pageNumber() %>
<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>
BListCommand.java
public class BListCommand implements BCommand {
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
BDao dao = new BDao();
String keyField = request.getParameter("keyField");
String keyWord = request.getParameter("keyWord");
System.out.println("키워드는~~:??"+keyField);
List<BDto> dtos ;
int totalCount = dao.getTotalRecord(keyField,keyWord);
System.out.println(totalCount);
int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
Paging paging = new Paging();
paging.setPageNo(page); //get방식의 parameter값으로 반은 page변수, 현재 페이지 번호
paging.setPageSize(10); // 한페이지에 불러낼 게시물의 개수 지정
paging.setTotalCount(totalCount);
paging.setKeyField(keyField);
paging.setKeyWord(keyWord);
System.out.println("페이지넘버BListCommand"+page);
page = (page - 1) * 10; //select해오는 기준을 구한다.
System.out.println("페이지넘버BListCommand"+page);
int endpage=page+10;
dtos = dao.getBoardList(page+1, endpage,keyField,keyWord);
request.setAttribute("paging", paging);
request.setAttribute("list", dtos);
request.setAttribute("keyField", paging.getkeyField());
request.setAttribute("keyWord", paging.getKeyWord());
}
}
答案 0 :(得分:1)
我相当确定您希望变量值是字符串。您需要编写:
body {
line-height: 1;
min-height: 100%;
position: relative; }
html {
min-height: 100%;
background-color: #3c3c3c; }
请注意,单引号会环绕Java的输出。这将使JavaScript将输出值视为字符串。现在,您输出它们的方式意味着它将它们视为变量名,但是这些变量当然在JavaScript中不存在。