数据库中有个性别的字段userSex, 数据是 0或者 1,在页面上查出来的时候如何让其显示男或者女,不是数字0或者1.应该怎么做,hibernate有这样的功能吗,求大侠帮助。。

解决方案 »

  1.   

    java里自己处理一下不就完了,
    或者在sql里直接中case when语句直接转过来。
      

  2.   

    用jstl 判断 如果为0 则显示男 如果为1则显示女
      

  3.   


    怎么判断啊,
    <%if(${employee.sex}=='1'){%><td height="25" align="center" width="120" class="b1_text_12_n">男</td>
    <%}%>
    <%else{%>
    <td height="25" align="center" width="120" class="b1_text_12_n">女</td>
    <%}%>这样吗?
      

  4.   

    <c:if test="${employee sex == 1}">
    <td height="25" align="center" width="120" class="b1_text_12_n">男</td></c:if>
    <c:if test="${employee sex == 0}">
    <td height="25" align="center" width="120" class="b1_text_12_n">女</td></c:if>
      

  5.   

    显示的时候<%%>里面if ele一下就行了
    或者直接批量的用sql的update把数据改成男和女;
    update table set userSex='男' where userSex=0;
    update table set userSex='女' where userSex=1;
      

  6.   

    页面小脚本<%
    if(usersex==1)
      {
      out.pirint("男");
      }else{
      out.print("女");
      }%>
      

  7.   

    c标签应该可以吧:
    <c:if test="${employee.userSex==1 }">
      <td>男</td>
    </c:if>
    <c:if test="${employee.userSex==0 }">
      <td>女</td>
    </c:if>
      

  8.   

    最简单的应该是写个三目吧${userSex==1?"男性":"女性"}
      

  9.   

    select case when userSex = 0 then '男' else '女' end userSex
    from table_name
    where userId = ?