沒有條件查詢,正常,按條件查詢時(shí),查詢不出結(jié)果,log日志中的sql正確,在數(shù)據(jù)庫(kù)中執(zhí)行可以查詢到結(jié)果
? <select id="queryMessage2" parameterType="com.immoc.bean.Message" resultType="com.immoc.bean.Message" >
? ? SELECT id as id, command as command, description as description, content as content FROM message where 1=1
? ? <if test="command!=null and !"".equals(command.trim())">
? ? and command=#{command}
? ? </if>
? ? <if test="description!=null and !"".equals(description.trim())">
? ? and description like '%' #{description} '%'
? ? </if>
? </select>
為什么我這樣配置,按條件查詢,查詢不出結(jié)果呢?
2016-04-28
我搞了幾個(gè)小時(shí)快崩潰了
我特意回來(lái)解答一下問題 :
url地址后面添加?useUnicode=true&characterEncoding=UTF-8,問題就可以解決了
mysql默認(rèn)是GBK編碼的 我們輸入的字符會(huì)轉(zhuǎn)化為UTF-8 所以亂碼了 匹配不上
2015-09-03
你那個(gè)解決了嗎?我 也出了這么個(gè)問題。。。
2015-08-15
dao中設(shè)置查詢參數(shù)時(shí),先trim()一下
2015-08-12
同學(xué),請(qǐng)問這個(gè)問題你解決了么?我也出現(xiàn)這個(gè)問題了。怎么解決的呢?