Spring MVC,如何将对象从JSP传递给Controller

时间:2018-02-01 14:55:02

标签: java jsp spring-mvc

我的JSP中有以下代码:

<c:forEach var="resultDisplay" items="${listResultDisplay}">
            <form:form method="POST"
                    action="${pageContext.request.contextPath}/display" modelAttribute="resultDisplay">
                    <!-- create an html table row -->
                    <tr>
                        <!-- create cells of row -->
                        <td>${resultDisplay.date}</td>
                        <td>${resultDisplay.documentDisplays[0].idNumber}</td>
                        <td>${resultDisplay.siret}</td>
                        <td align="center">

                             <input type="submit"
                            class="btn btn-success" value="Rechercher" name="sync"
                            id="monSubmit" /></td>

                        <!-- close row -->
                    </tr>
                    <!-- close the loop -->
                </form:form>
            </c:forEach>

我有一个Controller初始化了一个对象列表&#34; resultDisplay&#34;。 我迭代List的每个对象。

当我提交它时,它会将我的对象发送给新的控制器:

@Controller
public class ResultController {

    @RequestMapping(value = "/display", method = RequestMethod.POST)
    public ModelAndView displayResult(HttpServletRequest httpServletRequest,
            @ModelAttribute("resultDisplay") ResultDisplay resultDisplay) {

        return new ModelAndView("display", "result", resultDisplay);
    }

}

我的对象神经器出现在我的控制器中.... 当我处于调试模式时,我的控制器中的对象为空

PS:我想通过这个控制器把我的对象发送到一个新的JSP,我不需要操纵它

0 个答案:

没有答案
相关问题