2016-12-23 4 views
0

私はスプリングブート、java、およびmongodbを使用しています。ボタンをクリックしたときに表の行を編集しようとしています。私の現在のスクリプトでは、私は追加と削除ができますが、私は編集できません。私のメソッドにリンクし、私が編集している値を表示しますが、submitをクリックするとRequestメソッドが返されます。 'POST'はサポートされていません。編集中にリクエストメソッド 'POST'がTHYMELEAFでサポートされていません

コントローラサンプル

//adds values that are inputted in a form 
    @RequestMapping(value = "/addServer", method = RequestMethod.POST) 
public String saveProduct(ApServerModel apServerModel){ 
    apServerService.saveApServerModel(apServerModel); 
    return "redirect:editApServer"; 
} 

//update script in controller 
@RequestMapping("editApServer/update/{id}") 
public String update(@PathVariable String id, Model model) { 
    model.addAttribute("server", apServerService.getApServerModelById(id)); 
    return "update"; 
} 

@RequestMapping("editApServer/new") 
public String newServer(Model model){ 
    model.addAttribute("server", new ApServerModel()); 
    return "update"; 
} 

HTMLサンプル

//index.html 
     // adding works this works. 
     <h2>Add AppPortServer</h2> 
     <form action="/addServer" method="POST"> 
      Host <input type="text" id="host" name="host" /><br /> 
      Port <input type="text" id="port" name="port" /><br /> 
      <input type="submit" /> 
     </form> 

    //update.html 
//method "post" in here is throwing me an error. 
<h2>Server Details</h2> 
    <div> 
     <form class="form-horizontal" th:object="${server}" th:action="@{/editApServer}" method="POST"> 
      <input type="hidden" th:field="*{id}"/> 

      <div class="form-group"> 
       <label class="col-sm-2 control-label">Host:</label> 
       <div class="col-sm-10"> 
        <input type="text" class="form-control" th:field="*{host}"/> 
       </div> 
      </div> 
      <div class="form-group"> 
       <label class="col-sm-2 control-label">Port:</label> 
       <div class="col-sm-10"> 
        <input type="text" class="form-control" th:field="*{port}"/> 
       </div> 
      </div> 

      <div class="row"> 
       <button type="submit" class="btn btn-default">Submit</button> 
      </div> 
     </form> 
    </div> 

答えて

2

あなたの休憩中にPOSTメソッドがaddServerパスで注釈されているが、HTMLでフォームメソッドの動作が指していますeditApServer

変更th:action="@{/editApServer}"からth:action="@{/addServer}"

関連する問題