I would do it directly in the value attribute using the conditional operator ?: .
<c:set var="liclass" value="${rowStatus.first ? 'first' : ''}" /> <c:set var="liclass" value="${liclass}${rowStatus.last ? ' last' : ''}" />
For the not-so-beautiful part <li> I’ll just add
<c:set var="liclass" value="${empty liclass ? 'none' : liclass}" />
and do
<li class="${liclass}">
True, it adds the seemingly useless class="none" for non-first / last elements, but who cares?
As for the specific question, you can trim the spaces to the left of taglibs by setting the trimDirectiveWhitespaces attribute in @page to true .
<%@page trimDirectiveWhitespaces="true" %>
(works only in Servlet 2.5 / JSP 2.1 containers)
You can also configure it at the servletcontainer level. Since it is not clear which one you are using, here is an example of Apache Tomcat: in the JSP servlet entry in Tomcat/conf/web.xml add / edit the following initialization parameter:
<init-param> <param-name>trimSpaces</param-name> <param-value>true</param-value> </init-param>
In any case, I can not say from above, nor can I guarantee that he will achieve the desired effect by reaching the first last . You should try to try yourself.
source share