在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