欧泳洋
不错的!!!!!
梦影剑魂
public static boolean endsWith(String input, String substring)
{
if (input == null)
input = "";
if (substring == null)
substring = "";
int index = input.indexOf(substring);//此处应该是lastIndexOf
if (index == -1)
return false;
if (index == 0 && substring.length() == 0)
return true;
return (index == input.length() - substring.length());}以上是JSTL的endsWith的源码,可以看出存在一些bug
http://stackoverflow.com/questions/16750540/jstl-bug-in-function-endswith
慕粉3904766
public static boolean endsWith(String input, String substring) {
if(input == null) {
input = "";
}
if(substring == null) {
substring = "";
}
int index = input.indexOf(substring);
return index == -1?false:(index == 0 && substring.length() == 0?true:index == input.length() - substring.length());
}
这是它的源码,你看了这个应该就明白了,
最后index == input.length() - substring.length(),在helle中,input.length()为5,而substring.length()为1,
而index为1,所以index!=5-1,所以返回false
红袖侍读
<c:out value="“你好,Hello World中是否包含“world”${fn:containsIgnoreCase('你好Hello World','world')}"></c:out>