<%
Vector colorCollection=new Vector();
colorCollection.add(new org.apache.struts.util.LabelValueBean("显示内容1","值1"));
colorCollection.add(new org.apache.struts.util.LabelValueBean("显示内容2","值2"));
pageContext.setAttribute("colorCollection",colorCollection);
%><html:select property="colors" multiple="true">
<html:options collection="colorCollection" property="value" labelProperty="label"/>
</html:select>
Vector colorCollection=new Vector();
colorCollection.add(new org.apache.struts.util.LabelValueBean("显示内容1","值1"));
colorCollection.add(new org.apache.struts.util.LabelValueBean("显示内容2","值2"));
pageContext.setAttribute("colorCollection",colorCollection);
%><html:select property="colors" multiple="true">
<html:options collection="colorCollection" property="value" labelProperty="label"/>
</html:select>
解决方案 »
- 怎样在jquery easyui 中组合使用校验validType
- mybatis如何协调mapper
- jcrontab的配置和使用 如果谁做过可以近来看看
- 谁能讲一下EJB3开发流程,以及开发利器
- comet遇到500异常后就不再与服务器建立链接了怎么处理?
- JavaBeans的問題
- 找不到类org.apache.xml.serialize.XMLSerializer;
- 简单的问题~~
- jdbc for access 驱动在哪下载?急,再线等
- 怎样用java将xml文件的文件数据,转化成二维表格的形式
- 菜鸟问题:J2EE和J2SE有什么区别
- J2EE中三层有哪三层各有什么作用?高手帮忙谢谢!100分哈
显示页面
------------------------------------------
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<jsp:useBean scope="page" id="Test" class="com.hdtq.main.Testbean"/>
<jsp:getProperty name="Test" property="search"/>
....
<html:select property="username">
<html:option value="">--</html:option>
<html:options collection="Test" property="provinceid" labelProperty="provincename"/>
</html:select>
.....
---------------------------------------
Testbean.java
--------------------------------------
public class Testbean { public Collection getSearch(){
DBCPool dbc= new DBCPool();
Connection conn=dbc.getConnection("school_1");
Statement stmt=null;
Collection mylist1=new ArrayList();
if(conn!=null){
try{
stmt=conn.createStatement();
}catch(SQLException err){
System.out.println(err.getMessage());
}
}
ResultSet rs=null;
try{
rs=stmt.executeQuery("select provinceID,province from province");
Test test;
while(rs.next()){
test=new Test();
test.setProvinceid(rs.getString("provinceID"));
test.setProvincename(rs.getString("province"));
mylist1.add(test);
}
}catch(Exception er){
System.out.println(er.getMessage());
}
try{
stmt.close();
conn.close();
}catch(Exception err1){
System.out.println(err1.getMessage());
}
return mylist1;
}
}
---------------------------------
报的是这样的错误...........
Cannot create iterator for com.hdtq.main.Testbean......过来帮帮我吧
如果 要是从bean中读取 应该怎么做?
我的代码 有什么问题?
while(rs.next()){
org.apache.struts.util.LabelValueBean test=new org.apache.struts.util.LabelValueBean(rs.getString("province"),rs.getString("provinceID")));
mylist1.add(test);
}
然后把集合放到页面容器里,如request,session,pageContext等等页面使用
<html:options collection="colorCollection" property="value" labelProperty="label"/>
我试试
问题不段出现.唉
好使了,我其实想要做个 级联菜单的(省,市,县),用ajax实现下拉菜单中内容的变换,
你那有 struts+ajax的级联菜单吗