異常描述: java
Cause: java.sql.SQLException: sql injection violation, syntax error: web
異常信息:sql
SQL:spa
<insert id="addFloorGoods" parameterType="Map"> INSERT INTO home_floor_goods( floor_code, sku_code, display_sequence, website_code) VALUES <foreach collection="array" item="code" separator=","> (#{code.floorCode}, #{code.itemSkuCode}, (SELECT IFNULL(a.sum,1) FROM ( SELECT (MAX(display_sequence) + 1) sum FROM home_floor_goods) a) #{websiteCode}) </foreach> </insert>
SQL問題:code
少寫了一個 , blog
<insert id="addFloorGoods" parameterType="Map"> INSERT INTO home_floor_goods( floor_code, sku_code, display_sequence, website_code) VALUES <foreach collection="array" item="code" separator=","> (#{code.floorCode}, #{code.itemSkuCode}, (SELECT IFNULL(a.sum,1) FROM ( SELECT (MAX(display_sequence) + 1) sum FROM home_floor_goods) a), #{websiteCode}) </foreach> </insert>
總結:it
出現這種報錯,檢查思路io
1. 檢查出錯的地方,字符是否正確或者多寫或者少寫了字符class
2.若是沒有找到,手動書寫一遍foreach
3. 考慮關鍵字是否衝突