-1

I'm doing an if statement in mybatis, and <if test="param.equals('Y')"> returns false even when the param is "Y", but <if test="param.equals('Yes')"> returns true when the param is "Yes", why is this?

Rivaldo
  • 33
  • 5

1 Answers1

2

it seems you're trying to compare string with char, would you please do that instead

<if test='param.equals("Y")'>

or you can use == in mybatis so in this case the statement would be

<if test="param == 'Y'">
Osman
  • 66
  • 1
  • 8
  • 1
  • 1
    exactly, in sql side, you're totally in the mybatis' territory so there may not be support for all java-side methods, it'd be beneficial to use "==" for comparisons since they do alike this in their website – Osman Jan 28 '22 at 08:47
  • With `` , it gives Cause: java.lang.NumberFormatException: For input string: \"Y\"\r\n### error. But `` worked! thank you – Rivaldo Jan 29 '22 at 02:09