如何在JSP中检查输入字符串是否包含指定的子字符串?
的FN:含有()函数确定的输入字符串是否包含指定的子串。
语法
fn:contains()函数具有以下语法-
boolean contains(java.lang.String, java.lang.String)
示例
以下示例说明了fn:contains()函数的功能-
<%@ 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>Using JSTL Functions</title>
</head>
<body>
<c:set var = "theString" value = "我是测试字符串"/>
<c:if test = "${fn:contains(theString, 'test')}">
<p>Found test string<p>
</c:if>
<c:if test = "${fn:contains(theString, 'TEST')}">
<p>Found TEST string<p>
</c:if>
</body>
</html>您将收到以下结果-
Found test string
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短