如何将查询结果0,1,2转化为对应的“状态1”“状态2”“状态3”?数据库中已经查询出结果集 用request.setAttribute("list",list);传到前端页面,前段页面中 用logic标签 做迭代输出 查询数据
<logic:present name="list">
<logic:iterate id="bean" name="list" indexId="index">
<bean:write name="bean" property="status" />现在的问题是,查出来的是字符1,2,3 。 我想转化为汉字:“状态1”“状态2”“状态3” 这个该如何实现啊?页面中,我想到用map
<% Map map = new HashMap();
map.put("0","正常");
map.put("1","国内");
map.put("2","国外");
String status = <bean:write name="bean" property="cfdStatus" /> ;
再显示
<%= map.get(status)%>
但是不能这么写,红字部分由错误,如何才能将值赋给status呢?
或者有其他写法吗?
我知道c:foreach 也能实现 但是不太熟悉,最好是logic迭代实现 。
<logic:present name="list">
<logic:iterate id="bean" name="list" indexId="index">
<bean:write name="bean" property="status" />现在的问题是,查出来的是字符1,2,3 。 我想转化为汉字:“状态1”“状态2”“状态3” 这个该如何实现啊?页面中,我想到用map
<% Map map = new HashMap();
map.put("0","正常");
map.put("1","国内");
map.put("2","国外");
String status = <bean:write name="bean" property="cfdStatus" /> ;
再显示
<%= map.get(status)%>
但是不能这么写,红字部分由错误,如何才能将值赋给status呢?
或者有其他写法吗?
我知道c:foreach 也能实现 但是不太熟悉,最好是logic迭代实现 。
<c:if test="${list.status==2}" var="true">状态2</c:if>
<c:if test="${list.status==3}" var="true">状态3</c:if>
<c:when>
都行!
改成<%= map[status]%>呢?JSF里面好像是可以这么写的,
<c:if test="${list.status==2}" var="bb">状态2 </c:if>
<c:if test="${list.status==3}" var="cc">状态3 </c:if>
oracle中,用
decode转化一下
<c:if test="${list.status==2}" var="bb">状态2 </c:if>
<c:if test="${list.status==3}" var="cc">状态3 </c:if>
第二个赋值问题 :
<bean:define id="test" name="subject" property="context"/>
<%
String i=test.toString();
%>