在mysql中我有一個存儲過程,其中包含一個sql:
select firstname as i_firstname , lastname as i_lastname from roleuser
where user_id = uid ;
我使用jstl代碼來獲取值: –
call sp_select_username(?);
${rows.i_firstname} ${rows.i_lastname}
但是這個代碼不返回任何東西,但是當用${rows.firstname}替換上面的代碼${rows.i_firstname}時,我得到了正確的值.
jstl有什么問題,這是可復制的還是我的錯…
謝謝
解決方法:
重要的是,mysql論壇中的海報說明
ResultSetMetaData.getColumnName() will return the actual name of the column, if it exists
這提供了一種解決方法 – 防止列名存在,因此必須使用別名.例如,原始海報的存儲過程可以修改為
select concat(first name,'') as i_firstname ,
concat(lastname,'') as i_lastname from roleuser
where user_id = uid ;
在這種情況下,原始列現在是未知的,并使用別名.我已經在類似的情況下在我的系統上對它進行了測試.同樣,如果需要為int使用別名,可以嘗試SELECT(id 0)AS id_alias.我敢肯定大多數列類型都有類似的解決方案.希望這可以幫助.
標簽:java,mysql,jsp,stored-procedures,jstl
來源: https://codeday.me/bug/20190626/1297207.html