Paolo
Paolo

Reputation: 2472

String comparison is case sensitive in Expression language?

So just as simple as that. Comparing two strings that differs only for case

${"a" == "A"}

returns true or false?

Upvotes: 0

Views: 2826

Answers (2)

Jasper de Vries
Jasper de Vries

Reputation: 20253

It's case sensitive, so it will return false. Another possibility to do a case insensitive comparison of strings is using JSTL functions:

${fn:toLowerCase(stringA) == fn:toLowerCase(stringB)}

This is useful for older versions of EL. See https://stackoverflow.com/tags/el/info and scroll to "Invoking non-getter methods".

Upvotes: 2

Nikkster
Nikkster

Reputation: 327

When two strings are compared in EL, the comparison is always case-sensitive. If you want to do a string comparison that's not case-sensitive, you can just use the equalsIgnoreCase method.

That comparison would return false.

Upvotes: 3

Related Questions