Mysql 带hibernate Post的Spring不工作

Mysql 带hibernate Post的Spring不工作,mysql,spring,hibernate,spring-mvc,Mysql,Spring,Hibernate,Spring Mvc,我已经花了2天没有这个代码,我仍然无法找到问题所在 我想提交一个表格,进入数据库,当我提交我的表格时,它不会显示任何错误,但它不会提交 我的代码在下面我做错了什么 控制器 @RequestMapping(value = { "/newcustomer" }, method = RequestMethod.GET) public String newcustomer(ModelMap model) throws Exception { Customers customers

我已经花了2天没有这个代码,我仍然无法找到问题所在

我想提交一个表格,进入数据库,当我提交我的表格时,它不会显示任何错误,但它不会提交

我的代码在下面我做错了什么

控制器

@RequestMapping(value = { "/newcustomer" }, method = RequestMethod.GET)
    public String newcustomer(ModelMap model) throws Exception {
        Customers customers = new Customers();
        model.addAttribute("customerForm", customers);
        model.addAttribute("editt", false);
        model.addAttribute("newcustomer", getPrincipal());
        return "newcustomer";
    }

    @RequestMapping(value = { "/newcustomer" }, method = RequestMethod.POST)
    //public String saveCustomers(@Valid Customers customers, BindingResult result, ModelMap model) 
    public String saveCustomers(@ModelAttribute("customerForm") Customers customers, BindingResult result, ModelMap model){

        if (result.hasErrors()) {
            return "newcustomer";
        }

        if (!customersService.isCustomersPhoneUnique(customers.getIdCustomers(), customers.getCustomerPhone())) {
            FieldError CustomerPhoneError = new FieldError("customers", "CustomerPhone", messageSource
                    .getMessage("non.unique.CustomerPhone", new String[] {customers.getCustomerPhone()  }, Locale.getDefault()));
            result.addError(CustomerPhoneError);
            return "newcustomer";
    }
我的看法

<form:form method="POST" modelAttribute="customerForm"
                                    class="form-horizontal well">
                                    <fieldset id="newcustomer">
                                        <form:input type="hidden" path="idCustomers" id="id" />

                                        <div class="control-group">
                                            <label class="control-label" for="customerName">Customer
                                                Name</label>
                                            <div class="controls">
                                                <form:input type="text" path="CustomerName"
                                                    id="customerName" class="form-control span5" />
                                                <div class="has-error">
                                                    <form:errors path="CustomerName" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label" for="company">Company</label>
                                            <div class="controls">
                                                <form:input type="text" path="Company" id="company"
                                                    class="form-control span5" />
                                                <div class="has-error">
                                                    <form:errors path="Company" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label" for="phone">Cell Phone</label>
                                            <div class="controls">
                                                <form:input type="text" path="CustomerPhone" id="phone"
                                                    class="form-control span5" />
                                                <div class="has-error">
                                                    <form:errors path="CustomerPhone" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label" for="email">Email
                                                Address:</label>
                                            <div class="controls">
                                                <form:input type="text" path="CustomerEmail" id="email"
                                                    class="form-control span5" />
                                                <div class="has-error">
                                                    <form:errors path="CustomerEmail" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group ">
                                            <label class="control-label" for="name">Customer
                                                UserName:</label>
                                            <div class="controls">
                                                <form:input id="name" path="CustomerLoginName" type="text"
                                                    class="form-control span3" />
                                                <div class="has-error">
                                                    <form:errors path="CustomerLoginName" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group ">
                                            <label class="control-label" for="asset">Asset/Device
                                                Make/Model:</label>
                                            <div class="controls">
                                                <form:input id="asset" path="DeviceModel" type="text"
                                                    class="form-control span3" />
                                                <div class="has-error">
                                                    <form:errors path="DeviceModel" class="help-inline" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="input-append date" id="datepicker"
                                            data-date="12-02-2012" data-date-format="dd-mm-yyyy">
                                            <div class="control-group">
                                                <label class="control-label" for="date"> Scheduled
                                                    Date/Time:</label>
                                                <div class="controls">
                                                    <div class="input-append">
                                                        <form:input id="date" path="PickupDate" type="text"
                                                            class="form-control span6" />
                                                        <span class="add-on margin-fix"><i class="icon-th"></i></span>
                                                        <div class="has-error">
                                                            <form:errors path="PickupDate" class="help-inline" />
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label" for="note">Notes</label>
                                            <div class="controls">
                                                <form:textarea id="note" path="Note" rows="5" />

                                            </div>
                                            <div class="has-error">
                                                <form:errors path="Note" class="help-inline" />
                                            </div>
                                        </div>

                                        <div class="control-group">
                                            <label class="control-label" for="dop">Description of
                                                Problem Work to be Performed:</label>
                                            <div class="controls">
                                                <form:textarea id="dop" path="DescriptionofProblem" rows="7" />

                                            </div>
                                            <div class="has-error">
                                                <form:errors path="DescriptionofProblem" class="help-inline" />
                                            </div>
                                        </div>

<form:input type="hidden" path="DateCreated" id="idd" />
                                        <div class="control-group">
                                            <div class="controls">
                                                <h1>Other Asset/Device Info</h1>
                                            </div>
                                        </div>
                                        <div class="form-actions">
                                            <c:choose>
                                                <c:when test="${editt}">
                                                    <input type="submit" value="Update"
                                                        class="btn btn-primary " /> or <a
                                                        href="<c:url value='/customlist' />">Cancel</a>
                                                </c:when>
                                                <c:otherwise>
                                                    <input type="submit" value="Add" class="btn btn-primary" /> or <a
                                                        href="<c:url value='/customlist' />">Cancel</a>
                                                </c:otherwise>

                                            </c:choose>
                                        </div>
                                    </fieldset>
                                </form:form>

我的控制器是问题还是视图?

在您的表单中,您没有定义操作属性

试着加上这个

<form:form method="POST" modelAttribute="customerForm" action="/newcustomer" class="form-horizontal well">


您可以在表单字段中写入任何文本吗?我尝试了你的代码,但我甚至不能在文本输入中单击areas@Ivan你有什么例外吗?请求是done@cralfaro不,我没有exception@IvanPaitoo您是否向表单中添加了action属性?@cralfaro是的,当我添加action@IvanPaitoo您能否检查网络选项并检查调用POST操作的URL是否正确?
<form:form method="POST" modelAttribute="customerForm" action="/newcustomer" class="form-horizontal well">