Mybatis中if test 標籤遇到的問題Cause: java.lang.NumberFormatException: For input string: "="

1.在在這裏插入圖片描述

<if test="role.flightNo.tagList0.size()>0 and role.flightNo.tagList0[0]=='='">

中報異常Cause: java.lang.NumberFormatException: For input string: “=”
造成這個原因是將’='誤認爲char類型,而不是String類型

解決方案:
1.改爲:test=“role.flightNo.tagList0[0]==’=’.toString()”
2.原因是OGNL語法的問題:
這裏 ‘=’ 將被認爲是 char 類型,但是希望"=" 將被作爲 String類型。
所以我們可以用轉義:<if test="role.flightNo.tagList0[0]== &quot;=&quot;">
3.或者將<if test="index == '='"> 改爲 <if test='index == "="'>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章