[英]href parameter : scriplet result truncated at first white space in a jsp
[英]white space in JSP
我想知道如何檢查JSP字符串中是否有空格。
例如:
字符串名稱=“ Richard hailes”;
我想知道上面的字符串中是否有空格。
<c:if test="${fn:contains(name, ' ')}">
It contains a space
</c:if>
有關JSTL的信息,請參見https://stackoverflow.com/tags/jstl/info 。
public static boolean isBlank(String str){int strLen; if(str == null ||(strLen = str.length())== 0){返回true;} for(int i = 0; i <strLen; i ++){if(((Character.isWhitespace(str.charAt (i))==假)){返回假;}}返回真;}}
使用正則表達式。 看到這個例子;
String patternStr = "\\s+";
String inputStr = "Richard hailes";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
if(matcher.find()) {
System.out.println("Found");
} else {
System.out.println("Not Found");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.