Mybatis3 if judges string perversion
- 2020-05-27 05:31:46
- OfStack
mybatis, a common nulling operation, has encountered common problems:
Incorrect writing:
if test=”status == ‘Y'”
Result: throw exception NumberFormatException exception! The prompt content is very little, can't see what the problem is!
Correct writing:
if test='status == “y”'
You could also write:
if test=”status == ‘y'.toString()”
Or you could write it this way
if test ='status==”Y”'
Addition: Mybatis3 judges strings
A strange problem was found when using Mybatis3. The specified format must be used to determine the string
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>
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, and the same applies to the if tag