Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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
Java 从Html表单提交对象_Java_Html_Forms_Spring_Generics - Fatal编程技术网

Java 从Html表单提交对象

Java 从Html表单提交对象,java,html,forms,spring,generics,Java,Html,Forms,Spring,Generics,在我的spring项目中,我有以下表单,需要从中向服务器提交一个新实体: <%@ include file="../include/header.jsp" %> <form:form class="form" role="form" action="${action}" method="post"> <table> <c:forEach var="item" items="${elements}"> &l

在我的spring项目中,我有以下表单,需要从中向服务器提交一个新实体:

<%@ include file="../include/header.jsp" %>

<form:form class="form" role="form" action="${action}" method="post">

    <table>
        <c:forEach var="item" items="${elements}">
        <tr>
            <td><form:label path="${item}">${item}</form:label></td>
            <td><form:input type="" path="${item}" /></td> 
        </tr>
        </c:forEach>
        <tr>
            <td colspan="2">
                <button type="submit" class="btn btn-lg btn-primary">Cadastrar</button>
            </td>
        </tr>
    </table>

</form:form>

<%@ include file="../include/result.jsp" %>

<%@ include file="../include/footer.jsp" %>
其中,对象应该是所有实体类的通用父类

有什么办法可以让这一切顺利进行吗?此方法来自泛型控制器,每个专用控制器将用从对象派生的特定实体类的名称替换E。

的可能重复项
@RequestMapping(value="cadastra", method=RequestMethod.POST)
@ResponseBody
public String cadastra(@ModelAttribute("object") E object, BindingResult result) {
    if(serv.cadastra(object))
        return "yes";
    else
        return "not";
}