2017-07-05 110 views
1

enter image description hereformValidation不阿賈克斯

這是從JavaScript我的代碼提交,當我試圖做一個HTTP POST pettition這個發送數據作爲HTTP GET。

點後發送路徑爲GET HTTP。

這是我的HTML表單的客戶:

   <!-- form to client --> 
       <form id="formClient" class="form-horizontal form-label-left"> 

       <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" /> 
       <span class="section">Informacion Personal</span> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="telephone">Telefono <span class="required">*</span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input type="text" name="phone" data-fv-integer-message="The value is not an integer" placeholder="Telefono" class="form-control col-md-7 col-xs-12"/> 
        </div> 

        </div> 
        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Nombre del Cliente <span class="required">*</span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input class="form-control col-md-7 col-xs-12" name="name" placeholder="Nombre" type="text"/> 
        </div> 
        </div> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="lastname">Apellidos <span class="required">*</span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input class="form-control col-md-7 col-xs-12" name="lastname" placeholder="Apellidos" type="text"/> 
        </div> 
        </div> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="city">Ciudad <span class="required">*</span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <select name="city" class="form-control"> 
         <option value="">Seleccione..</option> 
         <option value="Cartago">Cartago</option> 
         <option value="Heredia">Heredia</option> 
         <option value="Alajuela">Alajuela</option> 
         <option value="Limon">Limon</option> 
         <option value="San Jose">San jose</option> 
         <option value="Puntarenas">Puntarenas</option> 
         <option value="Alajuela">Guanacaste</option> 
         </select> 
        </div> 
        </div> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Correo <span class="required">*</span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input type="email" name="email" placeholder="Correo" class="form-control col-md-7 col-xs-12"/> 
        </div> 
        </div> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="state">Permitir Fiado <span class="required"></span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input type="checkbox" name="guarantor" class="js-switch" checked="checked" /> Fiado 
        </div> 
        </div> 

        <div class="item form-group"> 
        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="state">Usuario <span class="required"></span> 
        </label> 
        <div class="col-md-6 col-sm-6 col-xs-12"> 
         <input type="checkbox" name="state" class="js-switch" checked="checked" /> Activo 
        </div> 
        </div> 

        <div class="ln_solid"></div> 
        <div class="form-group"> 
        <div class="col-md-6 col-md-offset-3"> 
         <button id="sendClient" type="submit" class="btn btn-success">Guardar Cliente</button> 
        </div> 
        </div> 
       </form> 
       <!-- /form to client --> 
+0

告訴我們您的標記'

' –

+0

有它的HTML表單 –

回答

0

它看起來像在創建表,您沒有使用方法,你可以使用:

<form id="formClient" class="form-horizontal form-label-left" method="post"> 

我創建了一個小提琴:輸出似乎使用方法後要更改。請讓我知道如果任何進一步的援助requried: Fiddle

+0

是的,我做到了,但控制檯顯示我:白色標籤錯誤頁面 此應用程序有沒有顯式映射/錯誤,所以你將這看作是後備。 星期三7月5日3點09分24秒CST 2017 有意外的錯誤(類型=不允許的方法,狀態= 405)。 請求方法「POST」不支持,服務器返回此請求方法「POST」不支持 –

+0

@你需要在你的控制器來定義一個POST requestMapping項來處理這些類型的請求 – cralfaro

+0

我控制器接收@PostMappingJustinZuñigaTorres(「/管理員/ clients/add「)這個HTTP POST –