struts 2已經推出了很久了,與struts 1.X有比較大的區別,不過熟悉struts 1的人對于struts 2應當是很快就能上手的。今天在開發過程中,想到利用iterate標簽來遍歷Map對像,在網上找了一個struts 1.x利用iterate來遍歷MAP的方法
<%
HashMap months = new HashMap();
months.put("Jan.", "January");
months.put("Feb.", "February");
months.put("Mar.", "March");
request.setAttribute("months", months);
%>
<logic:iterate id="element" indexId="ind" name="months">
<bean:write name="ind"/>.
<bean:write name="element" property="key"/>:
<bean:write name="element" property="value"/>
</logic:iterate>
但是在struts 2里面沒有<bean:write property=""/>這樣的標簽對象,不過從上面我們也可以大概推出struts 2的寫法
<s:terate value="months" state="stat">
<s:property value="key"/>:
<s:property value="value"/>
</s:iterate>
從上面我們可以看出,其實他們實現思想都是一樣的
評論
只有注冊用戶登錄后才能發表評論。 | ||
![]() |
||
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
相關文章:
|
||