select选择框实现

第一种:HTML

<select name="type"  >  
    <option value="0" >周转箱</option>  
    <option value="1"  >虚拟箱</option>  
</select> 

 第二种struts2

直接在前台定义SELECT

<s:select label="选择您喜欢的图书" name="book" list="#{'Spring2.0':'李刚','J2EE':'李','Ajax宝典':'李'}"
     listKey="value"  listValue="key">

 从后台action传list到前台。

 

第三种,采用freemaker

前台页面代码

	<td>
                   <select name="test" style="width:120px">
                          <#if cityList??>
                 		<#list cityList as item>
                 			<option value="${item.getId()}" >${item.getCity()}</option>
                 		</#list>
                 	 </#if>
                     </select>
       </td>
 

后台代码:

private List<city> cityList;

//action

public String editCity(){
	//查询列表数据
	List<city> cityList = cityService.findTmsBoxListByDto();
	return EDIT;
}

 public List<city> getCityList(){
        return cityList;
}

//列表类
class city{
	private String id;
	private String city;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
};
 

 

你可能感兴趣的:(html,Ajax)