ITeye博客

oralce中根据查询参数判断返回值

chwshuang · 2011-08-20 12:08 · database · 数据库 · Markdown

查询状态的时候,数据库字段一般为数字,0或者1,0代表未读,1代表已读,页面需要显示已读或者未读,所以sql语句应该是:

 

 

select 
    a.name ,
    a.id,
    a.location ,
    case a.status 
        when 0 then 'YES' 
         else 'NO' end
    from 
        user as a

 

 

现在的问题是当  case a.status
        when 0 then '已读'
         else '未读' end
    from
        user as a

JSP页面中显示的字符为‘???’乱码

oracle中的字符集为 SIMPLIFIED CHINESE_CHINA.ZHS16GBK

jsp页面字符为UTF-8 <%@ page contentType="text/html;charset=UTF-8"%>

页面进行转码也貌似不行。

new String(status.getBytes("iso8859-1"), "utf-8");

所以这点要注意。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。