简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM