當deveui什麼都不輸,傳到後臺的是空串"",因為js中是這樣寫的
var deveui = $("#dev_lc_deveui").val(); //是空串""
注意:var deveui; //是undefined,傳到後臺是null
過濾條件
<if test='p.deveui != null'>
AND t.DEVEUI = #{p.deveui, jdbcType=VARCHAR}
</if>
由於沒有加空串判斷,所以出現了AND t.DEVEUI = ?結果查不到值
SELECT
t.DEVEUI AS deveui,
t.DEVTYPE AS devType,
t.ORDNO AS ordNo,
t.CLAANO AS claaNo,
t.DEVSTATUS AS devStatus,
t.OPTIME AS opTime,
t.REMARK AS remark,
t.PROJECTID AS projectid,
t.ADDRESS AS address,
t.GPSLAT AS gpslat,
t.GPSLNG AS gpslng,
t.GPSALT AS gpsalt
FROM osmdb.t_osm_dev t
WHERE 1 = 1
AND t.DEVEUI = ?
ORDER BY t.CLAANO, t.ORDNO, t.DEVEUI
LIMIT ? OFFSET ?
加了空串判斷,則deveui不會出現
<if test='p.deveui != null and p.deveui != ""'>
SELECT
t.DEVEUI AS deveui,
t.DEVTYPE AS devType,
t.ORDNO AS ordNo,
t.CLAANO AS claaNo,
t.DEVSTATUS AS devStatus,
t.OPTIME AS opTime,
t.REMARK AS remark,
t.PROJECTID AS projectid,
t.ADDRESS AS address,
t.GPSLAT AS gpslat,
t.GPSLNG AS gpslng,
t.GPSALT AS gpsalt
FROM osmdb.t_osm_dev t
WHERE 1 = 1
ORDER BY t.CLAANO, t.ORDNO, t.DEVEUI
LIMIT ? OFFSET ?
-----------------------------------------------------------------------------
點選修改,把以前remark的值刪了,什麼都不輸入,進行update,傳到後臺的是空串"",
UPDATE osmdb.t_osm_dev t
SET t.DEVTYPE = ?,
t.ORDNO = ?,
t.CLAANO = ?,
t.DEVSTATUS = ?,
t.OPTIME = ?
WHERE t.DEVEUI = ?
由於被osmDev.remark != ""過濾
<if test='osmDev.remark != null and osmDev.remark != "" '>
t.REMARK = #{osmDev.remark, jdbcType=VARCHAR},
</if>
沒有出現在update語句中
去掉osmDev.remark != "",則remark出現
UPDATE osmdb.t_osm_dev t
SET t.DEVTYPE = ?,
t.ORDNO = ?,
t.CLAANO = ?,
t.DEVSTATUS = ?,
t.OPTIME = ?,
t.REMARK = ?
WHERE t.DEVEUI = ?
----------------------------------------------------------------------------------
點選修改,把以前remark的值刪了,輸入一大堆空格,進行update,傳到後臺的是空串" ",
後臺過濾條件
<if test='osmDev.remark != null and osmDev.remark != "" '>
t.REMARK = #{osmDev.remark, jdbcType=VARCHAR},
</if>
結果過濾不掉,說明""和" "不是一個東西
----------------------------------------------------------------------------------
當輸入"",過濾條件
<if test='osmDev.remark != null and osmDev.remark != "" '>
t.REMARK = #{osmDev.remark, jdbcType=VARCHAR},
</if>
我本以為會被過濾掉,結果沒有,把""儲存進去了
傳到後臺的引數是"""",說明這不是空串,所以沒有過濾掉
https://blog.csdn.net/th_datou/article/details/39477157