单击“提交”按钮后如何将表数据发送到控制器

时间:2016-04-20 10:10:50

标签: html spring

我有一个数据表来自数据库的表格,我想在将值赋予Text1,Text2并将其发送给控制器之后更新表格,我该怎么办呢。

HTML

<form  action="/update" method="post" > 
        <table border="1">
            <thead> 
                <tr>
                    <th data-field="id"> ID </th>
                    <th data-field="details"> Details </th>
                    <th data-field="report"> Report </th>
                    <th data-field="value"> value </th>
                    <th data-field="destination"> Destination </th>
                </tr>
            </thead>
            <c:forEach items="${List2}" var="as">
            <tr >
                <td>${as.id}</td>
                <td>${as.rulDetails}</td>
                <td>${as.rulName}</td>
                <td><input type="text" name ="Text1">
                <td>${as.rulValue}</td>
                <td><input type="text" name ="Text2">
                </td>
            </tr>                           
            </c:forEach>    
</table>
            <input type="submit" value="Update"></input>

这是我的更新表的servlet,我没有写任何东西,因为我不知道我怎么能这样做。

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(@ModelAttribute("SpringWeb") AssignmentDetails asd  ModelMap model) {  

       //what i should write here..?


    return "hello"; 
}

请告诉我/帮帮我需要做什么?我需要修改什么。请给我一个建议或帮助。

谢谢

1 个答案:

答案 0 :(得分:0)

请参阅this教程。

您可以使用spring taglibs。

<form:form method="post" modelAttribute="SpringWeb" action="/update">
   <form:input path="Text1" type="text" />
   <form:input path="Text2" type="text" />
</form:form>
相关问题