gpt4 book ai didi

java - 从模态窗口获取值

转载 作者:行者123 更新时间:2023-12-01 16:57:29 27 4
gpt4 key购买 nike

我在从模态窗口获取字段值时遇到问题。

 <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModal" aria-hidden="true">
<form th:action="@{/groups/add}" method="post">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addModal">Add group</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="recipient-name" class="col-form-label">Group Name</label> <input type="text"
class="form-control" id="addName" name="name">
</div>
<div class="form-group">
<label for="recipient-name" class="col-form-label">Faculty</label> <select
class="form-control">
<option th:value=0>Faculty not assign</option>
<option th:each="faculty : ${faculties}" th:value="${faculty.id}"
th:utext="${faculty.name}">Faculty</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</div>
</form>
</div>

在浏览器中,当我使用“添加”方法时,我可以从表中选择任何教师,它工作正常,但是当我按下“保存”按钮时,只有名称返回到 Controller ,而没有有关所选教师的信息。我错过了什么?

最佳答案

最后我解决了这个问题 - 我忘记为存储 coachId 的字段命名。这是错误:

<label for="recipient-name" class="col-form-label">Faculty</label> 
<select class="form-control">

正确:

<label for="faculyId" class="col-form-label">Faculty</label> 
<select class="form-control" id="addFaculty" name="facultyId">

关于java - 从模态窗口获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61567094/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com