pager taglib 没有按照记录重命名导出的 url 变量
我正在使用这个 pager taglib 解决方案,它生成指向几乎按照指示翻页。它提供了一种自定义用于迭代数据集的变量名称的方法,而这正是导致问题的原因。
这就是我到目前为止的设置方式
<pg:pager url="/search"
items="1000"
maxPageItems="10"
export="from=offset,currentPageNumber=pageNumber"
scope="request">
<pg:param name="w" value="${w}"/>
<pg:param name="e" value="${e}"/>
<pg:first unless="current"><a href="${pageUrl}"> << first</a> </pg:first>
<pg:prev><a href="${pageUrl}"> < prev</a> </pg:prev>
<pg:pages>
<c:choose>
<c:when test="${pageNumber == currentPageNumber}">
${pageNumber}
</c:when>
<c:otherwise>
<a href="${pageUrl}">${pageNumber}</a>
</c:otherwise>
</c:choose>
</pg:pages>
<pg:next><a href="${pageUrl}">next ></a> </pg:next>
<pg:last unless="current"><a href="${pageUrl}">last >></a></pg:last>
</pg:pager>
注意,基于 文档您可以控制导出变量的名称
导出表达式export="versatz=offset"会导致 pageOffset 变量可用作 <%=Versatz %>
正如您所看到的,我正在尝试将 offset 重命名为 from (这是后端所期望的),
export="from=offset,currentPageNumber=pageNumber"
但是所有生成的链接都采用以下形式( >注意 pager.offset=[number])
http://localhost:8080/search?w=param1&e=param2&pager.offset=10
那是什么,我做错了? 有人尝试过这个标签库吗?
非常感谢任何反馈
I'm using this pager taglib solution, it generates the links to the pages almost as instructed. It offers a way to customize the variable names that are used to iterate over the data set, and that's precisely what is causing problems.
This is how I've got set up so far
<pg:pager url="/search"
items="1000"
maxPageItems="10"
export="from=offset,currentPageNumber=pageNumber"
scope="request">
<pg:param name="w" value="${w}"/>
<pg:param name="e" value="${e}"/>
<pg:first unless="current"><a href="${pageUrl}"> << first</a> </pg:first>
<pg:prev><a href="${pageUrl}"> < prev</a> </pg:prev>
<pg:pages>
<c:choose>
<c:when test="${pageNumber == currentPageNumber}">
${pageNumber}
</c:when>
<c:otherwise>
<a href="${pageUrl}">${pageNumber}</a>
</c:otherwise>
</c:choose>
</pg:pages>
<pg:next><a href="${pageUrl}">next ></a> </pg:next>
<pg:last unless="current"><a href="${pageUrl}">last >></a></pg:last>
</pg:pager>
Note, that based on the documentation you can control the name of the exported variables
The export expression export="versatz=offset" would cause the
pageOffset variable to be available as <%= versatz %>
As you can see I'm trying to rename too the offset to from (This is what the backend is expecting)
export="from=offset,currentPageNumber=pageNumber"
But all the generated links are in the form (Note the pager.offset=[number])
http://localhost:8080/search?w=param1&e=param2&pager.offset=10
What's that, that I'm doing wrong?
Anybody has experimented with this taglib?
Any feedback is deeply appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我意识到这有点晚了,但我使用上面提到的寻呼机标签库来支持单个页面上的多个唯一寻呼机时遇到了同样的问题。希望有人发现这很有用...
似乎这个参数名称已融入寻呼机标签源代码中:
但是,有一个
id
标签属性,其值以OFFSET_PARAM
标签渲染期间上面的常量。它的默认值为pager
:这两个值连接起来形成一个
idOffsetParam
字段,该字段是 pager 标记内部使用的最终参数名称:解决方案:如果您在标记声明中指定自己的
id
值,您将可以部分控制呈现的参数名称:这将使导航链接呈现为
?stackoverflow.offset=10< /代码>。参数的
.offset
部分将保留,但至少您对参数名称的唯一性有一定的灵活性。I realize this is a bit late, but I encountered this same issue using the pager taglib mentioned above to support multiple unique pagers on a single page. Hope someone finds this useful...
It seems this parameter name is baked into the pager tag source code:
However, there is an
id
tag attribute whose value gets prefixed to theOFFSET_PARAM
constant above during tag rendering. Its default value ispager
:These two values get concatenated to form an
idOffsetParam
field which is the final parameter name used internally by the pager tag:Solution: If you specify your own
id
value in the tag declaration, you'll have partial control over the rendered parameter name:This will make navigational links render as
?stackoverflow.offset=10
. The.offset
portion of the param will remain, but at least you'll have some flexibility as to the uniqueness of the parameter name.