jstl tag -- c:choose and fn function

来源:互联网 发布:java定义数组函数 编辑:程序博客网 时间:2024/06/07 01:27

fn:indexOf(s1, s2)

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
<title>c:choose, c:when and c:otherwise Tag Example</title>
</head>
<body>
<c:set var="s1" value="Jobs with"/>
<c:set var="s2" value="a"/>
<c:choose>
 <c:when test="${fn:indexOf(s1, s2) == -1}">
     <p>not there</p>
 </c:when>
 <c:otherwise>
    <p>yes</p>
 </c:otherwise>
</c:choose>
</body>
</html>

fn:contains(s1, s2)

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<html>

<head>

<title>c:choose, c:when and c:otherwise Tag Example</title>

</head>

<body>

<c:set var="s1" value="Jobs with"/>

<c:set var="s2" value="w"/>

<c:choose>

<c:when test="${fn:contains(s1, s2)}">

<p>yes</p>

</c:when>

<c:otherwise>

<p>no</p>

</c:otherwise>

</c:choose>

</body>

</html>


0 0
原创粉丝点击