java.lang.IllegalStateException: Optional int parameter 'currentSpecialIndex' is present but cannot

來源:互聯網
上載者:User
java.lang.IllegalStateException: Optional int parameter 'currentSpecialIndex' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

spring mvc 封裝參數猜想
1. 如果用對象來接受參數 spring 會首先new 一個對象出來然後將傳過來的匹配到屬性的值賦給屬性。
2. 如果在方法中直接寫變數來接受前台的參數 如果匹配到變數則賦值 如果前台沒有對應變數的參數spring會給該變數一個null 值而不是改變數類型的預設值。
public Knowledge findVideoBySpecialId(int specialId,int currentPage)
以上問題是因為我定義了一個int類型的變數來接受參數傳入但是前台並沒有傳入該參數所以sping給一個null 但是null並不能賦值給int 所以引發異常 可以考慮用string 類型或者將參數封裝為對象 或者用該類型的封裝類型。

—待驗證啊。。。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.