el表达式的问题
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<jsp:useBean id="get" class="com.biz.MessageList" />
<c:set var="MessageInfo" value="${get.MessageInfo}" scope="session"/>
<c:forEach var="uses" items="sessionScope.MessageInfo" varStatus="status"/>
<body>
${uses.MessageInfo }
</body>
页面显示
public List<Message> getMessagte(){
List<Message> messageL= new ArrayList<Message>();
super.openConn();
try {
String sql = "select * from Message";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
Message ms=new Message();
ms.setFromId(rs.getInt(1));
ms.setMessageInfo(rs.getString(2));
ms.setToId(rs.getInt(3));
ms.setIsOpen(rs.getInt(4));
ms.setDate(rs.getDate(5));
messageL.add(ms);
}
} catch (
SQLException e) {
e.printStackTrace();
}
finally{
super.closeAll();
}
return messageL;
}
}
为什么el表达式吧出来?菜鸟提问。。。有get set
------解决方案--------------------
el表达式获取的值是需要放在属性范围中的比如:
HTML code
<body>
<%
String admin="jianglh";
request.setAttribute("str",admin);
String[] a=new String[5];
a[0]="1";
a[2]="2";
a[1]="3";
request.setAttribute("array",a);
List list = new ArrayList();
list.add("aa");
list.add("bb");
list.add("cc");
request.setAttribute("arraylist",list);
%>
<c:if test="${str=='admin'}">
<c:out value="${str}"></c:out>
</c:if>
el: expression:${array[0] }<br>
<hr>
el:expression :${arraylist[1] }<br>
c:lable <c:forEach items="${arraylist}" var="tt">
${tt}
------解决方案--------------------
------解决方案--------------------
++