仅检查 <s:if test=""> 标记中的 endswith() 的最佳方法,包括 Struts2 中的 equalsIgnorecase

Best way to just check endswith() in <s:if test=""> tag including equalsIgnore case in Struts2

检查字符串是否以特定字母结尾(包括 equalsIgnore 大小写)的最佳方法是什么。

我想实现类似下面的效果 + 仅使用 struts2 标签而不是 jstl 标签忽略区分大小写。

<s:if test="(strDisplay.endsWith('XYZ'))">

我没有使用过 Struts 2 个标签,但我认为代码在您的表达式语言中 Java 代码

所以

试试这个

strDisplay.toLowerCase().endsWith('XYZ'.toLowerCase())

想法很简单,您应该将两个字符串转换为 UppercaseLowerCase 以实现 endsWithIgnoreCase

Struts2 支持通过 OGNL 调用函数。

<s:if test="strDisplay.toUpperCase().endsWith('XYZ')">