簡體   English   中英

如何在Spring框架中使用顯示標簽跳轉到特定頁碼

[英]How to jump to specific page number using display tag in Spring framework

我想使用帶有文本框和“轉到”按鈕的顯示標簽跳轉到特定的頁碼。 單擊“開始”按鈕將調用一個javascript,該javascript中應通過未發生的.htm轉到該特定頁面。 請為獲取特定頁面的這種特定方式建議一個參數,否則總是歡迎其他建議。以下是到目前為止我知道的displaytag.properties中的參數

在這里輸入代碼

{0}: numbered pages list
{1}: link to the first page
{2}: link to the previous page
{3}: link to the next page
{4}: link to the last page
{5}: current page
{6}: total number of pages

下面是單擊GO按鈕時調用的javascript函數

function selectPage(){
 alert("pageNo:" +document.portalDisplayform.selPageNo[0].value);
 alert("pageNo:" +document.portalDisplayform.selPageNo[1].value);
 var pageNo = document.portalDisplayform.selPageNo[0].value;
 var pageNo = document.portalDisplayform.selPageNo[1].value;
 document.portalDisplayform.action = '<%=request.getContextPath()%      >'+"/portalAccessdisplay.htm?tokenId="+'<%=cachetoken%>'+pageNo;
 document.portalDisplayform.submit();

}

最簡單的方法是,可以修改顯示標簽jar文件中的TableTag.java 在此文件中,修改initParameters()方法。 在方法內部放置下面的4行代碼。 在此行之后是initParameters()方法中。

this.pageNumber = (pageNumberParameter == null) ? 1 : pageNumberParameter.intValue();

放置下面的代碼

if((request.getParameter("pageno") != null) && (request.getParameter("pageno") != ""))
{
     this.pageNumber=Integer.parseInt(request.getParameter("pageno"))
}     

並在DisplayTag頁面中使用名稱為pageno的TextBox 還包括你的名字DisplayTag屬性excludedparam

這並不是一件容易的事,因為displaytag會對參數進行編碼(以避免與功能參數命名沖突),並且在同一頁上有多個表的情況下,每個表使用唯一的ID。 我建議您下載displaytag的源代碼,看看ParamEncoder和Pagination類(及其調用者)以發現displaytag如何構建指向特定頁面的鏈接。 您將必須使用類似的代碼來生成URL,並且必須在JavaScript代碼中修改適當(編碼)參數的值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM