简体   繁体   English

如何在Spring框架中使用显示标签跳转到特定页码

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

I want to jump to a specific page number using display tag with a textbox and a "go" button. 我想使用带有文本框和“转到”按钮的显示标签跳转到特定的页码。 On the click of GO button calls a javascript in which it should go to that specific page through that .htm which is not happening. 单击“开始”按钮将调用一个javascript,该javascript中应通过未发生的.htm转到该特定页面。 please suggest an argument for this particular way of getting a specific page or else alternate suggestions are always welcome Below are the arguments in displaytag.properties which i know so far 请为获取特定页面的这种特定方式建议一个参数,否则总是欢迎其他建议。以下是到目前为止我知道的displaytag.properties中的参数

enter code here 在这里输入代码

{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

Below is the javascript function which is being called on click of GO button 下面是单击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();

} }

The very easiest way, you can modify the TableTag.java which is in the display-tag jar file. 最简单的方法是,可以修改显示标签jar文件中的TableTag.java In this file modify the initParameters() method. 在此文件中,修改initParameters()方法。 Inside the method place the below 4 line code. 在方法内部放置下面的4行代码。 After this line which is in initParameters() method. 在此行之后是initParameters()方法中。

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

Place the below code 放置下面的代码

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

And use a TextBox with the name pageno in your DisplayTag page. 并在DisplayTag页面中使用名称为pageno的TextBox Also include the name in your DisplayTag property excludedparam . 还包括你的名字DisplayTag属性excludedparam

It's not so easy, because the displaytag encodes parameters (to avoid naming conflicts with functional parameters), and uses a unique ID per table, in case several tables are on the same page. 这并不是一件容易的事,因为displaytag会对参数进行编码(以避免与功能参数命名冲突),并且在同一页上有多个表的情况下,每个表使用唯一的ID。 I suggest you download the source code of displaytag, have a look at the ParamEncoder and Pagination classes (and their callers) to discover how a link to a specific page is constructed by the displaytag. 我建议您下载displaytag的源代码,看看ParamEncoder和Pagination类(及其调用者)以发现displaytag如何构建指向特定页面的链接。 You'll have to use similar code to generate the URL, and you'll have to modify the value of the appropriate (encoded) parameter in your JavaScript code. 您将必须使用类似的代码来生成URL,并且必须在JavaScript代码中修改适当(编码)参数的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM