struts模式下設置html:select初始值

 使用html:select標籤,不能像在html中使用select標籤一樣,只在<option></option> 中設置selected就可以設置默認值。而應該在<html:select>中來設。如:

<html:select property="discountType"  value="2" οnchange="showPage(discountType)" >
          <html:option value="1"><bean:message key="discountType.holiday" /></html:option>
          <html:option value="2"><bean:message key="discountType.week" /></html:option>
          <html:option value="3"><bean:message key="discountType.date" /></html:option>
         </html:select>

加上:value="**",這樣就可以將其初始值設爲2,頁面則顯示其對應的信息<bean:message key="discountType.week" />

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章