第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

全查詢可以查出,條件查詢不到,疑惑???幫忙看下哪有問(wèn)題。。。

看之前有童鞋出了這問(wèn)題,然后說(shuō)在Dao中trim()了,我試了,沒效果。代碼如下:

Dao層:

//獲取message表中數(shù)據(jù)

public List<Message> messagelist(String command,String description){

List<Message> messagelist = null;

//調(diào)用Dao操作方法

//messagelist = this.dbaccess(command,description);

//調(diào)用Mybatis方式操作方法

SqlSession sqlSession = null;

Message message = new Message();

//檢索數(shù)據(jù)處理

if(command !=null&&!"".equals(command.trim())){

message.setCommand(command.trim());

}

if(description !=null&&!"".equals(description.trim())){

message.setDescription(description.trim());

}

try {

//獲取sqlSession

sqlSession = this.dbaccess.mybatis();

//查詢messagelist

messagelist = sqlSession.selectList("Message.messagelist",message);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

finally{

//關(guān)閉數(shù)據(jù)庫(kù)連接會(huì)話

if(sqlSession != null){

sqlSession.close();

}

}

mappersql.xml配置文件:

?<select id="messagelist" parameterType="blue.java.model.Message" resultMap="MessageResult">

? ? select id,command,description,content from message where 1=1

? ? <if test="command != null ">

? ? and command = #{command}

? ? </if>

? ? <if test="description != null">

? ? and description like '%' #{description} '%'

? ? </if>

? </select>

日志打印如下:

DEBUG [http-8080-2] - Opening JDBC Connection

DEBUG [http-8080-2] - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@1dc696e]

DEBUG [http-8080-2] - ==> ?Preparing: select id,command,description,content from message where 1=1 and command = ??

DEBUG [http-8080-2] - ==> Parameters: 查看(String)

DEBUG [http-8080-2] - <== ? ? ?Total: 0

DEBUG [http-8080-2] - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@1dc696e]

DEBUG [http-8080-2] - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@1dc696e]


正在回答

5 回答

新建數(shù)據(jù)庫(kù)表的時(shí)候默認(rèn)是GBK的編碼,自己改一下UTF-8就行了UTF-8,

mybatis也設(shè)置了默認(rèn)的編碼是UTF-8吧,

0 回復(fù) 有任何疑惑可以回復(fù)我~

我也出現(xiàn)了這個(gè)情況,eclipse文件編碼和數(shù)據(jù)庫(kù)編碼都確認(rèn)過(guò)是utf-8,最后還是在url追加的編碼,難道以后都要這樣嗎?

0 回復(fù) 有任何疑惑可以回復(fù)我~

我搞了幾個(gè)小時(shí)快崩潰了

我特意回來(lái)解答一下問(wèn)題 :

url地址后面添加?useUnicode=true&amp;characterEncoding=UTF-8,問(wèn)題就可以解決了

mysql默認(rèn)是GBK編碼的 我們輸入的字符會(huì)轉(zhuǎn)化為UTF-8 所以亂碼了 匹配不上


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

java家洼

您好,您說(shuō)mysql默認(rèn)是GBK編碼的,那您怎么不把mysql的默認(rèn)編碼方式改成UTF-8,那這樣就不用每次在mybatis的主配置文件中的url后面追加?useUnicode=true&amp;characterEncoding=UTF-8了?再請(qǐng)問(wèn)您怎么知道m(xù)ysql的默認(rèn)編碼是GBK,您是從哪里看出來(lái)的?是mysql的配置文件中嗎?辛苦您了。
2016-06-08 回復(fù) 有任何疑惑可以回復(fù)我~

我轉(zhuǎn)碼了啊,還是查不出。條件查詢查不出,其他都沒事,也沒異常。

1 回復(fù) 有任何疑惑可以回復(fù)我~

問(wèn)題解決了,和jdbc時(shí)候一樣,需要設(shè)置字符集。。。一個(gè)坑栽了兩次,醉了。。。

2 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

全查詢可以查出,條件查詢不到,疑惑???幫忙看下哪有問(wèn)題。。。

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)