1 iterator
<select name="market.FROM_ID" class="input01 w_p95" title="输入公司信息来源">
<s:iterator value="#request.catList" status="id">
<option value="<s:property value="CAT_ID"/>"
<s:if test="%{CAT_NAME.equals(market.FROM_ID)}">selected=selected</s:if>>
<s:property value="CAT_NAME" />
</option>
</s:iterator>
</select>
2 <s:select>
<s:select headerKey="" headerValue="" listKey="CAT_ID" listValue="CAT_NAME" list="#request.catList" title="输入公司信息来源" id="id04"
name="market.FROM_ID" cssClass="input01 w_p95" />
注:selected属性好像不能使用
3 ajax查出数据
js:
$.getJSON("/html/call/getCatListCallMarketContactAction.do",null,function call(data) {
var len = $(data).length;
var str="";
for(var i=0;i<len;i++){
var myObj = $(data).get(i);
str+="<option value="+myObj.CAT_ID;
str+=">"+myObj.CAT_NAME+"</option>";
}
document.getElementById("id04").innerHTML = str;
})
jsp:
<select title="输入公司信息来源" id="id04" name="market.FROM_ID" class="input01 w_p75" />
java:
public void getCatList() throws Exception{
HttpServletResponse response = ServletActionContext.getResponse();
List<Call_category> fromList = callMarketContactService.categoryList();
Gson gson = new Gson();
String catListToJson = gson.toJson(fromList);
response.setCharacterEncoding("utf-8");
response.getWriter().write(catListToJson);
response.getWriter().close();
}
posted on 2012-06-15 12:33
canry Tong 阅读(220)
评论(0) 编辑 收藏 所属分类:
jsp