Mybatis' common empty-blank operation has common problems:
Wrong writing method: if test=”status == 'Y'”
Result: throw an exception NumberFormatException exception! There are very few prompts, so I can't see where the problem is!
Correct writing: if test='status == “y”'
You can also write this way: if test=”status == 'y'.toString()”
Or you can write if test ='status==”Y”'
Supplement: Mybatis3 judges string
I found a strange problem in using Mybatis3. I must use the specified format to determine the string.
The mapper is as follows:
<choose> <when test="regOrSign != null and regOrSign == 'R' "> ORDER BY a.registrationDate DESC </when> <otherwise> ORDER BY a.signDate DESC </otherwise></choose>
Report an error:
### Error querying database. Cause: java.lang.NumberFormatException: For input string: "R" ### Cause: java.lang.NumberFormatException: For input string: "R"] with root cause java.lang.NumberFormatException: For input string: "R"test=regOrSign != null and regOrSign == 'R' -> test='regOrSign != null and regOrSign == "R" '
Just change it to this, this problem also applies to the if tag
The above is the abnormal writing method of Mybatis3 if judging strings introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!