select下拉框回显的几种方式

第一种:

jsp代码:

[html]  view plain  copy
  1. <select id="csrqnf" name="csrqnf" id="selecte" class="shortselect" value="${nfResult}">  
  2.                                                                              <option value="">---请选择年份--option>  
  3.                                                                              <c:forEach items="${listYears}" var="years" varStatus="vs">    
  4.                                                                                  <option value="${years}">${years}option>  
  5.                                                                              c:forEach>  
  6.                                                                     select>  
  7.                                                                     <script type="text/javascript">  
  8.                                                                         document.getElementById("csrqnf").value="${nfResult}";  
  9.                                                                         document.getElementById("csrqnf")[${nfResult}].selectedtrue;  
  10.                                                                           
  11.                                                                     script>  


 

后台java代码:

[html]  view plain  copy
  1. request.setAttribute("nfResult","2013");  


 

 

 

网上摘抄:

[html]  view plain  copy
  1.   
  2. 1.<select name="curStatus"  value="${curStatus}">     
  3.   <option value="0">-请选择-option>     
  4.   <option value="1" <c:if test="${'1' eq curStatus}">selectedc:if> >option>     
  5.   <option value="2" <c:if test="${'2' eq curStatus}">selectedc:if> >option>  
  6.  select>  
  7.   
  8. 2.<s:select  list="#{0:'--请选择--',1:'处理中',2:'已完成'}" listKey="key" listValue="value" name="curStatus" value="%{curStatus}">s:select>        
  9.    
  10. 3.<select name="curStatus"  value="${curStatus}">     
  11.   <option value="0">-请选择-option>     
  12.   <option value="1" <s:if test="%{curStatus==1}">selecteds:if> >处理中option>     
  13.   <option value="2" <s:if test="%{curStatus==2}">selecteds:if> >已处理option>  
  14.  select>  

你可能感兴趣的:(学习)