public class MapBean {
private Map testMap = new HashMap();
public MapBean() {
testMap.put("key1", "value1");
testMap.put("key2", "value2");
testMap.put("key3", "value3");
testMap.put("key4", "value4");
testMap.put("key5", "value5");
}
public Map getTestMap() {
return testMap;
}
public void setTestMap(Map testMap) {
this.testMap = testMap;
}
}
xtml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<!-- 显示列表页面 -->
<h:form>
<h:panelGrid columns="2">
<c:forEach items="${mapBean.testMap}" var="entry">
<h:outputText value="${entry.key}" style="font:12px;width:20px;" />
<h:inputText value="${entry.value}" style="font:12px;width:150px;" />
</c:forEach>
</h:panelGrid>
</h:form>
</ui:composition>
已知key获取value的方法:
<fc:render debugMode="true"
chartId="#{inforReportBean.chartMap[row.cells[index-1].cellContent].chartID}"
filename="FusionCharts/#{inforReportBean.chartMap[row.cells[index-1].cellContent].chartStyle.chartFile}"
width="#{inforReportBean.chartMap[row.cells[index-1].cellContent].widthPx}"
height="#{inforReportBean.chartMap[row.cells[index-1].cellContent].heightPx}"
xml="#{inforReportBean.chartMap[row.cells[index-1].cellContent].dataxml}" />
获取数组的长度
- ${fn:length(listComment)}
- ${fn:length(listComment)}