測試的時候遇到一個問題: <c:out value="${fn:endsWith('helle','e') }"></c:out> <c:out value="${fn:endsWith('hhlle','e') }"></c:out> 訪問的時候顯示 false true 。 為什么啊啊????
測試的時候遇到一個問題:
<c:out value="${fn:endsWith('helle','e') }"></c:out>
<c:out value="${fn:endsWith('hhlle','e') }"></c:out>
訪問的時候顯示 false true 。 為什么啊??????
2016-10-28
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