现在有个页面:left.jsp,有个分页功能在在pageview.jspf中实现。
但是有个错误,如果只是在页面中引用一次pageview.jspf没问题,但是如果使用第二次时就报错。
引用的语句是: <%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
错误很奇怪:eclipse报的错:Syntax error, insert "Finally" to complete TryStatementleft.jsp:<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主题列表</title>
<%@ include file="/WEB-INF/pages/public/common.jspf" %>
<script type="text/javascript">function getPageViewUrl(pageNum){
return "?method=showLeft&id=${request_forum.id}&pageNum="+pageNum;
}
function toTopicAddUI(){
parent.right.document.location.href="${basePath}/topic.do?method=addUI&forumId=${request_forum.id}";
}</script>
<link href="${basePath}/style/forum_left.css" rel="stylesheet" type="text/css" charset="utf-8"/>
</head>
<body>
<div class="area_articlelist">
<%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
<ul>
<c:forEach items="${request_pageView.recordList}" var="topic">
<li class="${topic.type }">◆ <span style="color: #8a2be2">
<html:link action="/topic?method=show&id=${topic.id}&pageNum=1" target="right">【${topic.type}】<c:out value="${topic.title}"/></html:link></span>
(${topic.replyCount}回复)
</li>
</c:forEach>
</ul>
<%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
</div>
</body>
</html>
--------------------------------------------------------------------------------------------------
pageview.jspf:
<%@ page pageEncoding="utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:if test="${request_pageView.totalPage gt 1}">
<div class="pageView">分页:
<a href="javascript:gotoPage(1)">[首页]</a>
<c:forEach begin="${request_pageView.startPageIndex}" end="${request_pageView.endPageIndex}" var="pageNum">
<c:if test="${request_pageView.currentPage ne pageNum}">
<a href="javascript:gotoPage(${pageNum})">[${pageNum}]</a>
</c:if>
<c:if test="${request_pageView.currentPage eq pageNum}">
<span class="currentpage">[${pageNum }]</span>
</c:if>
</c:forEach>
<a href="javascript:gotoPage(${request_pageView.totalPage})">[尾页]</a>
<select name="pageNum" onchange="gotoPage(this.value)">
<c:forEach begin="1" end="${request_pageView.totalPage}" var="pageNum">
<option value="${pageNum }" ${request_pageView.currentPage eq pageNum ? 'selected=\\"selected\\"':''}>${pageNum }</option>
</c:forEach>
</select>
</div><script type="text/javascript">
function gotoPage(pageNum){
if(isNaN(pageNum)){
alert("请输入正确的页面");
document.getElementById('txtPageNum').focus();
return;
}
if(pageNum<1||pageNum>${request_pageView.totalPage}){
alert("请输入正确的页码,页面范围为 1-11");
document.getElementById('txtPageNum').focus();
return;
}
document.location.href=getPageViewUrl(pageNum);
}
</script>
</c:if>
但是有个错误,如果只是在页面中引用一次pageview.jspf没问题,但是如果使用第二次时就报错。
引用的语句是: <%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
错误很奇怪:eclipse报的错:Syntax error, insert "Finally" to complete TryStatementleft.jsp:<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主题列表</title>
<%@ include file="/WEB-INF/pages/public/common.jspf" %>
<script type="text/javascript">function getPageViewUrl(pageNum){
return "?method=showLeft&id=${request_forum.id}&pageNum="+pageNum;
}
function toTopicAddUI(){
parent.right.document.location.href="${basePath}/topic.do?method=addUI&forumId=${request_forum.id}";
}</script>
<link href="${basePath}/style/forum_left.css" rel="stylesheet" type="text/css" charset="utf-8"/>
</head>
<body>
<div class="area_articlelist">
<%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
<ul>
<c:forEach items="${request_pageView.recordList}" var="topic">
<li class="${topic.type }">◆ <span style="color: #8a2be2">
<html:link action="/topic?method=show&id=${topic.id}&pageNum=1" target="right">【${topic.type}】<c:out value="${topic.title}"/></html:link></span>
(${topic.replyCount}回复)
</li>
</c:forEach>
</ul>
<%@ include file="/WEB-INF/pages/public/pageview.jspf" %>
</div>
</body>
</html>
--------------------------------------------------------------------------------------------------
pageview.jspf:
<%@ page pageEncoding="utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:if test="${request_pageView.totalPage gt 1}">
<div class="pageView">分页:
<a href="javascript:gotoPage(1)">[首页]</a>
<c:forEach begin="${request_pageView.startPageIndex}" end="${request_pageView.endPageIndex}" var="pageNum">
<c:if test="${request_pageView.currentPage ne pageNum}">
<a href="javascript:gotoPage(${pageNum})">[${pageNum}]</a>
</c:if>
<c:if test="${request_pageView.currentPage eq pageNum}">
<span class="currentpage">[${pageNum }]</span>
</c:if>
</c:forEach>
<a href="javascript:gotoPage(${request_pageView.totalPage})">[尾页]</a>
<select name="pageNum" onchange="gotoPage(this.value)">
<c:forEach begin="1" end="${request_pageView.totalPage}" var="pageNum">
<option value="${pageNum }" ${request_pageView.currentPage eq pageNum ? 'selected=\\"selected\\"':''}>${pageNum }</option>
</c:forEach>
</select>
</div><script type="text/javascript">
function gotoPage(pageNum){
if(isNaN(pageNum)){
alert("请输入正确的页面");
document.getElementById('txtPageNum').focus();
return;
}
if(pageNum<1||pageNum>${request_pageView.totalPage}){
alert("请输入正确的页码,页面范围为 1-11");
document.getElementById('txtPageNum').focus();
return;
}
document.location.href=getPageViewUrl(pageNum);
}
</script>
</c:if>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货