表td数据需要从jsp发送到spring控制器

时间:2018-09-27 18:28:30

标签: html spring-mvc jsp post html-table

enter image description here

<form:form method="POST" modelAttribute="employees" action="/InternalApp/admin/saveShift">
    <%-- <form:input type="hidden" path="id" id="id"/> --%>
        <!-- HTML -->
        <table class="myTable" id="rosterTable">
            <col>
            <colgroup span="2"></colgroup>
            <colgroup span="2"></colgroup>
            <tr>

                <th colspan="1" scope="colgroup">Roster & Leave Details</th>
                <th colspan="1" scope="colgroup">Monday</th>
                <th colspan="1" scope="colgroup">Tuesday</th>
                <th colspan="1" scope="colgroup">Wednesday</th>
                <th colspan="1" scope="colgroup">Thursday</th>
                <th colspan="1" scope="colgroup">Friday</th>
                <th colspan="1" scope="colgroup" bgcolor="#feb236"><font
                    color="#feb236">Saturday</font></th>
                <th colspan="1" scope="colgroup" bgcolor="#feb236"><font
                    color="#feb236">Sunday</font></th>
            </tr>
            <tr>
                <th scope="col">${employees.currentWeek}'th-Week</th>
                <c:forEach items="${employees.days}" var="days">
                    <th scope="col">${days}</th>
                    <%-- <th scope="col">${days[1]}</th>
                    <th scope="col">${days[2]}</th>
                    <th scope="col">${days[3]}</th>
                    <th scope="col">${days[4]}</th>
                    <th scope="col">${days[5]}</th>
                    <th scope="col">${days[6]}</th> --%>
                </c:forEach>
            </tr>

            <tr>
                <th># Name</th>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
                <td>IST / Leave Details</td>
            </tr>
                <c:forEach items="${employees.listEmployee}" var="employee">
                    <tr>
                        <th scope="row">${employee.firstName}${employee.lastName}</th>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="A">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                        <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="Pins 2">Comp Off</form:option>
                            </form:select></td>
                            <td><form:select path="">
                                <form:option value="NONE"> --SELECT--</form:option>
                                <form:option value="">14:00-22:30</form:option>
                                <form:option value="">17:00-01:30</form:option>
                                <form:option value="">22:00-06:30</form:option>
                                <form:option value="">Leave</form:option>
                                <form:option value="">Holiday</form:option>
                                <form:option value="">Home</form:option>
                                <form:option value="">Comp Off</form:option>
                            </form:select></td>
                    </tr>
                </c:forEach>
            </table>
        </form:form>

提交此表格后,我需要将个人姓名和日期以及在选择框中选择的值保存到表格中。下表是我的表格(Winid是我们在左侧看到的名称,而shift值是选择框的值)

enter image description here

最后,数据应保存在下面的数据库中

1 09/24/2018假期(从选择框中选择)阿伦

2 09/25/2018假期Arun

如何从上面的jsp代码中获取td,th值。

请帮助。

0 个答案:

没有答案