是否可以创建一个接受非字符串属性的自定义JSTL标记?
我想创建一个标签,使用Spring MVC中的PagedListHolder来处理分页.
<%@tag body-content="scriptless" description="basic page template" pageEncoding="UTF-8"%>
<%-- The list of normal or fragment attributes can be specified here: --%>
<%@attribute name="pagedList" required="true" %>
<%-- any content can be specified here e.g.: --%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:choose>
<c:when test="${!pagedList.firstPage}">
<a href="
<c:url value="pagedList">
<c:param name="page" value="${pagedList.page - 1}"/>
</c:url>
"><<
</a>
</c:when>
<c:otherwise>
<<
</c:otherwise>
</c:choose>
<%-- ...more --%>
Run Code Online (Sandbox Code Playgroud)
此标记需要PagedListHolder类的实例.
有点像这样,但我意识到这是无效的.
<templ:pagedList pagedList="${players}"/>
Run Code Online (Sandbox Code Playgroud)
我是否需要编写标记处理程序来实现此目的?
您只需type在属性指令中指定属性即可.
<%@ attribute name="pagedList" required="true" type="org.springframework.beans.support.PagedListHolder" %>
Run Code Online (Sandbox Code Playgroud)