0

我是 Spring MVC 的新手,我在调试这个问题时有点卡住了。我从我的数据库中获取一些详细信息并将它们从我的控制器发送到 JSP,并且我能够正确显示它。当我出于某些测试目的尝试将相同的表单提交回控制器时,很少有属性值为空。

class Quote(){
    int id;
    String name;
    //getters and setter
}

class QuotesForm(){
    List<Quote> quotesList = new ArrayList<Quote>();
    //getters and setters
}


@Controller
class TestController{

        @RequestMapping(value = "/update_quotes", method = RequestMethod.POST)
        public String updateQuotes(@ModelAttribute("quotesForm") QuotesForm quotesForm,
                ModelMap model,
                HttpServletRequest request) {
            logger.info("update quotes method invoked");
            logger.info("quotesForm size " + quotesForm.getQuotesList().size());

            for (Quote quote : quotesForm.getQuotesList()) {
                logger.info(quote.getId() + " , " + quote.getName());
             }
           return "/list_quotes";
          }
}

这是我的jsp(预览)

    <form:form id="quotes_form" action="${pageContext.request.contextPath}/update_quotes" method="post" modelAttribute="quotesForm">
        <table>
            <c:forEach items="${quotesForm.quotesList}" var="quote" varStatus="status">
                <tr>
                    <td>    <form:input path="verticalsList[${status.index}].id" value="${quote.id}"/></td>
                    <td>   <form:input path="quotesList[${status.index}].name" value="${quote.name}" readonly="true"/></td>
                </tr>
            </c:forEach>
            <tr>
            <td colspan="2"> <input type="submit" value="Update" onclick='$("#quotes_form").submit();' /> </td>
            <tr>
        </table>
    </form:form>

这是我的控制器日志

2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1223 , Think like a proton... always positive...
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1224 , The best feeling on earth is love, and the worst feeling on earth is death...
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1225 , You cannot hide from yourself...
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1226 , null
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1227 , null
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1228 , null
2014-04-08 10:56:18,486 [http-bio-8080-exec-8] INFO  ui.controller.TestController  - 1229 , null

请帮助我理解并解决问题,如果您需要任何进一步的信息

4

1 回答 1

0

只是为了让别人知道;我详细检查了我的日志,发现实际问题是在给定的 GET/POST 请求中,tomcat 容器无法处理超过 10000 个键/参数-值对。我参考了这个链接并将 maxParameterCount="100000" 添加到我的 tomcat server.xml 中,它解决了这个问题。

于 2014-04-09T04:03:58.017 回答