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?
Asked
Active
Viewed 226 times
-1

Rivaldo
- 33
- 5
1 Answers
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
-
1And `
`? – Joop Eggen Jan 28 '22 at 08:44 -
1exactly, 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 ` – Rivaldo Jan 29 '22 at 02:09` worked! thank you