我通过扩展标准来实现 displaytag。请看下面的详细信息。
JSP
display:table name="testList" id="obj" requestURI="testAction.do?pageAction=init" pagesize="${paging_size}" sort="list" class="table" **sort="external"** excludedParams="*" decorator="dyndecorator" export="false" **keepStatus="true"**
display:setProperty name="pagination.pagenumber.param" value="page"
display:setProperty name="pagination.sort.param" value="sort" /
display:setProperty name="pagination.sortdirection.param" value="dir"
display:column property="testNo" title="Test no." **sortable="true"** **sortName="testNo"**
display:column property="testValue" title="Test value" **sortable="true"** **sortName="testValue"**
display:table
分页列表实现
public PaginatedListImpl(HttpServletRequest request) {
sortCriterion = request.getParameter("sort");
sortDirection = "desc".equals(request.getParameter("dir"))? SortOrderEnum.DESCENDING : SortOrderEnum.ASCENDING;
pageSize = DEFAULT_PAGE_SIZE;
String page = request.getParameter("page");
index = page == null? 0 : Integer.parseInt(page) - 1;
}
JAVA
public PaginatedListImpl getTest(
Criteria criList = session.createCriteria(TestDto.class);
criList.setFirstResult(pageDisplay.getFirstRecordIndex());
criList.setMaxResults(pageDisplay.getObjectsPerPage());
pageDisplay.setList(criList.list());
pageDisplay.setTotal((Integer) criTotal.uniqueResult());
return pageDisplay;
}
无论如何,当浏览器呈现结果时,我在浏览器上发现了问题
当我将鼠标移到 page_no 上时。它将显示“http://localhost:8080/WebProject/testAction.do? page=2 &pageAction=init”
当我将鼠标移到列名上时。它将显示“http://localhost:8080/WebProject/testAction.do? sort=testValue &* dir=asc *pageAction=init”
但我需要这样的链接“http://localhost:8080/WebProject/testAction.do? page=2&sort=testValue&dir=asc &pageAction=init”
我在谷歌上搜索了很多次,但我仍然有问题。
我能怎么做?有人请帮我解决问题。
十分感谢..