在我的jsp页面中,我指定:
<c:choose>
line 1: <c:when test="${com.community_classification_id.contains('1')}">
<input type="checkbox" id="by_invitation1" name="invitaion" value="1" checked="true">By Invitation<span style="padding-left:28px"></span>
</c:when>
<c:otherwise>
<input type="checkbox" id="by_invitation1" name="invitaion" value="1">By Invitation<span style="padding-left:28px"></span>
</c:otherwise>
</c:choose>
Run Code Online (Sandbox Code Playgroud)
但@line没有.1它给我500错误
The function contains must be used with a prefix when a default namespace is not specified
Run Code Online (Sandbox Code Playgroud)
我无法理解它.怎么了?
看看这个:JSTL fn:contains()函数
用于在另一个内部找到一个String(我想这是你想要实现的)
在你的代码中:
<c:choose>
<c:when test="${fn:contains(com.community_classification_id, '1')}">
<input type="checkbox" id="by_invitation1" name="invitaion" value="1" checked="true">By Invitation<span style="padding-left:28px"></span>
</c:when>
<c:otherwise>
<input type="checkbox" id="by_invitation1" name="invitaion" value="1">By Invitation<span style="padding-left:28px"></span>
</c:otherwise>
</c:choose>
Run Code Online (Sandbox Code Playgroud)
不要忘记在您的JSP中包含taglib以使用它:
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
Run Code Online (Sandbox Code Playgroud)