当我点击一个类别,它显示该类别的产品列表,网址将:
http://localhost:9999/toyshop/home?category=Đồ%20chơi%20theo%20phim
字符串
但是当我点击下一个分页页面时,URL将是
http://localhost:9999/toyshop/home?category{Đồ%20chơi%20theo%20phim}=Đồ%20chơi%20theo%20phim&page=2
型
这是我的jsp代码:
<c:remove var="param" scope="session" />
<c:remove var="paramValue" scope="session" />
<c:remove var="href" scope="session" />
<c:remove var="param" scope="request" />
<c:remove var="paramValue" scope="request" />
<c:remove var="href" scope="request" />
<c:choose>
<c:when test="${not empty sessionScope.productName}">
<c:set var="servlet" value="search"/>
<c:set var="param" value="product"/>
<c:set var="paramValue" value="${sessionScope.productName}"/>
</c:when>
<c:when test="${not empty sessionScope.categoryName}">
<c:set var="servlet" value="home"/>
<c:set var="param" value="category"/>
<c:set var="paramValue" value="${sessionScope.categoryName}"/>
</c:when>
<c:otherwise>
<!-- Handle the case where both are empty -->
<c:set var="servlet" value="home"/>
<c:set var="param" value=""/>
<c:set var="paramValue" value=""/>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${empty paramValue}">
<c:set var="href" value="${servlet}?"/>
</c:when>
<c:otherwise>
<c:set var="href" value="${servlet}?${param}=${paramValue}"/>
</c:otherwise>
</c:choose>
<c:if test="${currentPaginationPage > 1}">
<a href="${href}&page=${currentPaginationPage - 1}" class="pagination__item">
<i class="pagination__icon fas fa-chevron-left"></i>
</a>
</c:if>
<c:if test="${startPage > 1}">
<div class="pagination__item pagination__item--none">...</div>
</c:if>
<c:forEach begin="${startPage}" end="${endPage}" var="page">
<c:choose>
<c:when test="${page == currentPaginationPage}">
<a href="${href}&page=${page}" class="pagination__item pagination__item--active">${page}</a>
</c:when>
<c:otherwise>
<a href="${href}&page=${page}" class="pagination__item">${page}</a>
</c:otherwise>
</c:choose>
</c:forEach>
<c:if test="${endPage < totalPaginationPage}">
<div class="pagination__item pagination__item--none">...</div>
</c:if>
<c:if test="${currentPaginationPage < totalPaginationPage}">
<a href="${href}&page=${currentPaginationPage + 1}" class="pagination__item">
<i class="pagination__icon fas fa-chevron-right"></i>
</a>
</c:if>
型
我希望URL是
http://localhost:9999/toyshop/home?category=Đồ%20chơi%20theo%20phim&page=2
型
1条答案
按热度按时间oalqel3c1#
${param}
是EL中的一个保留变量。它基本上是HttpServletRequest#getParameter()
的一个隐式对象外观。您不应该尝试删除/覆盖它。请使用不同于
${param}
的名称。例如,${paramName}
。个字符
另请参阅: