Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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
Hibernate 如何设置组合框jsp的默认值_Hibernate_Jsp_Spring Mvc_Combobox - Fatal编程技术网

Hibernate 如何设置组合框jsp的默认值

Hibernate 如何设置组合框jsp的默认值,hibernate,jsp,spring-mvc,combobox,Hibernate,Jsp,Spring Mvc,Combobox,我想要设置默认值=${theObject2.countryId} 你可以用。只需比较Id并将其设置为选中(如果匹配) 示例代码: <select id="locationCountry" style="padding-left: 2em"> <option value="">Country</option> <c:forEach items="${countrieDetail}" var="theObject"> &

我想要设置默认值=${theObject2.countryId}

你可以用。只需比较Id并将其设置为选中(如果匹配)

示例代码:

<select id="locationCountry" style="padding-left: 2em">
    <option value="">Country</option>
    <c:forEach items="${countrieDetail}" var="theObject">
        <option value="${theObject.countryId}" <c:if test="${theObject.countryId == theObject2.countryId }">selected</c:if>>
              ${theObject.countryName}
        </option>
    </c:forEach>
</select>

您不能在支持表单的模型属性中设置默认值吗?然后Spring将只渲染具有所述值的组件。为什么要渲染对象2?2是一个打字错误?看看这篇文章,同样的逻辑被用来使它更清楚。
<select id="locationCountry" style="padding-left: 2em">
    <option value="">Country</option>
    <c:forEach items="${countrieDetail}" var="theObject">
        <option value="${theObject.countryId}" <c:if test="${theObject.countryId == theObject2.countryId }">selected</c:if>>
              ${theObject.countryName}
        </option>
    </c:forEach>
</select>