Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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 MVC JSP子下拉列表按父下拉选择项_Spring_Jsp_Model View Controller_Dropdown - Fatal编程技术网

Spring MVC JSP子下拉列表按父下拉选择项

Spring MVC JSP子下拉列表按父下拉选择项,spring,jsp,model-view-controller,dropdown,Spring,Jsp,Model View Controller,Dropdown,如何按父下拉列表中的选定项填充子下拉列表 例如: 我有一个ItemType列表,其中包含以下值: [ {id: 1, name: "Type 1"}, {id: 2, name: "Type 2"}, {id: 3, name: "Type 3"} ] [ {id: 1, name: "Item 1", itemTypeId: 1 }, {id: 2, name: "Item 2",

如何按父下拉列表中的选定项填充子下拉列表

例如:

我有一个ItemType列表,其中包含以下值:

[
 {id: 1, name: "Type 1"},
 {id: 2, name: "Type 2"},
 {id: 3, name: "Type 3"}
]
[
 {id: 1, name: "Item 1", itemTypeId: 1 },
 {id: 2, name: "Item 2", itemTypeId: 2 },
 {id: 3, name: "Item 3", itemTypeId: 3 },
 {id: 4, name: "Item 4", itemTypeId: 3 }
]
我还有另一个列表,Item,带有以下值:

[
 {id: 1, name: "Type 1"},
 {id: 2, name: "Type 2"},
 {id: 3, name: "Type 3"}
]
[
 {id: 1, name: "Item 1", itemTypeId: 1 },
 {id: 2, name: "Item 2", itemTypeId: 2 },
 {id: 3, name: "Item 3", itemTypeId: 3 },
 {id: 4, name: "Item 4", itemTypeId: 3 }
]
当我选择某个ItemType in时,我需要转到我的DB,找出哪个项目属于itemTypeId selected,并填充一个新的下拉列表

<form:select name="itemTypeId" path="itemTypeId" class="form-control">
    <c:forEach var="item" items="${itemTypeList}">
        <form:option value="${item.id}" label="${item.name}"></form:option>
    </c:forEach>
</form:select>

<!-- This select must have only items that belongs to itemTypeId selected above -->
<form:select name="itemId" path="itemId" class="form-control">
    <c:forEach var="item" items="${itemList}">
        <form:option value="${item.id}" label="${item.name}"></form:option>
    </c:forEach>
</form:select>

请帮帮我


谢谢。

在第一种形式中,您可以编写一个操作方法将其发送到servlet1,然后您可以根据itemTypeId找到第二个列表的值并将其发送回页面。有关更多详细信息,请参见。

。谢谢