Search code examples
javamybatisspring-mybatismybatis-mapper

Equals() returns false on 'Y' but returns true on 'Yes'


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?


Solution

  • 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'">