Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 弹簧下拉框_Spring_Jsp_Jstl_El - Fatal编程技术网

Spring 弹簧下拉框

Spring 弹簧下拉框,spring,jsp,jstl,el,Spring,Jsp,Jstl,El,我有一个选择框,类似于春季的以下内容 <form:select path="cmbZone" multiple="false" class="validate[required] text-input tooltip" title="Mandatory select field."> <form:option value="">Select</form:option> <c:forEach items="${zoneList}" var

我有一个选择框,类似于春季的以下内容

<form:select path="cmbZone" multiple="false" class="validate[required] text-input tooltip" title="Mandatory select field.">
    <form:option value="">Select</form:option>

    <c:forEach items="${zoneList}" var="row">
        <form:option value="${row[0]}">${fn:escapeXml(row[1])}</form:option>
    </c:forEach>
</form:select>
我想使用
实现同样的效果。如何指定
项目标签
项目值
属性


我正在使用Spring3.2.0。我指的是博客,但找不到方向。

将Hibernate查询更改为

List<Zone> zoneList = sessionFactory.getCurrentSession().createQuery(
    "select z from Zone z order by z.zoneId").list();
List zoneList=sessionFactory.getCurrentSession().createQuery(
“按z.zoneId“.list()从区域z顺序中选择z”;
现在已经有了具有属性的对象,可以使用

<form:options items="${zoneList}" itemLabel="zone" itemValue="zoneId"/>


那么,我们在这方面没有选择字段?数据库中的
Zone
表还有其他字段,包括
Zone
zoneId
,此处不需要检索这些字段。仅对选定字段不可能实现相同的效果吗?如果它适合于选择框,则加载所有字段与仅加载两个字段可能会产生微不足道的差异(如果有的话)。但您也可以创建一个LightZone对象,只包含两个字段,并为从原始查询中检索到的每一行创建LightZone实例。这已经完成,但使用
列表
真的不可能吗?只是好奇。在JSF中,如果我没记错的话,有一个
var
属性。因此,在那里应该是可能的。itemLabel和itemValue代表bean属性名,所以不,这是不可能的。您应该明确使用类型化对象,而不是对象数组。
<form:options items="${zoneList}" itemLabel="" itemValue=""/>
List<Zone> zoneList = sessionFactory.getCurrentSession().createQuery(
    "select z from Zone z order by z.zoneId").list();
<form:options items="${zoneList}" itemLabel="zone" itemValue="zoneId"/>