There is no getter for property named 'column' in 'class java.lang.String'] with root cause

來源:互聯網
上載者:User

近期做項目有一個需求類似這樣的:有一個city表,裡面有id,name兩個欄位,前端需要傳入選擇性的查詢出內容,比如傳入id就要(select id from city),傳入name就要(select name from city),傳入id,name就要select id,name from city.

需求大體是這樣,我之前寫的傳值方式是:

 

     sql的寫法是這樣的

    

在啟動並執行時候不出意外的報錯了:

 

解決方案就是:

當參數是String類型的時候,mybatis裡面參數統一寫成_parameter,


問題成功解決~~~


另外這個時候一定要用${},而不是#{},一樣的傳遞“id,name”:

${}傳遞,sql是這樣的:select id,name from city

#{}傳遞,sql是這樣的: select  ‘id,name’ from city


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.