ÔÚJSPÒ³ÃæÖÐÓÃselectÏÂÀÁбíÀ´ÏÔʾListÁбíµÄ·½Ê½
Ò» ¡¢ ÓÃstruts2±êÇ©µÄ<s:selectÀ´ÏÔʾ
<s:select cssStyle="width: 84%" list="#application.officeList" headerKey="" headerValue="--ÇëÑ¡Ôñ--" listKey="#this.value" listValue="#this.key+'.'+#this.value" name="entity.officeName" value="entity.officeName"/>
ÆäÖÐ
1¡¢listÊǽÓÊÕjavaÀà»òÕßÔÚÆô¶¯Ê±¾ÍÒѾ¼ÓÔصÄapplicationÖеÄlistÁбíÖµ £»
2¡¢listKeyµÄÖµÊÇselectµÄÖµ£»
3¡¢listValueµÄÖµÊÇÏ൱ÓÚ<selectÖÐÏÔʾ³öÀ´µÄtext£»
4¡¢valueÊÇjavaÀàÖд«À´µÄÖµ£¬ÓÃÀ´ÓëselectÁбíÖеÄoptionµÄidÖµ×ö¶Ô±È
¶þ ¡¢ÓÃ<select À´ÏÔʾ´ÓjavaÀà¶Ë´«¹ýÀ´µÄListÁбíÖеÄÑ¡Ïî
<select name="entity.officeName">
<option value="">--ÇëÑ¡Ôñ--</option>
<s:iterator value="#application.officeList" id="bean">
<option value="${bean.value}" <s:if test='#bean.key==entity.officeName'>selected</s:if> >${bean.key}.${bean.value}</option>
</s:iterator>
</select>
Ïà¹ØÎĵµ£º
JSP½Å±¾Öаüº¬9¸öÄÚÖöÔÏó£¬Õâ9¸öÄÚÖöÔÏó¶¼ÊÇServlet API½Ó¿ÚµÄʵÀý£¬Ö»ÊÇJSP¹æ·¶½«ËüÃÇÍê³ÉÁËĬÈϳõʼ»¯£¨ÓÉJSPÒ³Ãæ¶ÔÓ¦ServletµÄ_jspService()·½·¨À´´´½¨ÕâЩʵÀý£©¡£Ò²¾ÍÊÇ˵£¬ËüÃÇÒѾÊǶÔÏ󣬿ÉÒÔÖ±½ÓʹÓá£9¸öÄÚÖöÔÏóÒÀ´ÎÈçÏ£º
application£ºjavax.servlet.ServletContextµÄʵÀý£¬¸ÃʵÀý´ú±íJSPËùÊôµÄWebÓ ......
<table width=100% border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td height="1" class="gray1"></td>
</tr>
</table>
<tiles:insert attribute="footer" />
</body>
</html:html> ......
1 web·þÎñÆ÷{TOMCAT(JSP)¡¢WEBLOGIC(JSP) }
Ó¦Ó÷þÎñÆ÷
We ......