SpringMVC找不到post方法的表示形式

SpringMVC找不到post方法的表示形式,spring,model-view-controller,thymeleaf,Spring,Model View Controller,Thymeleaf,在将ELEAF模板映射到Spring控制器时遇到问题。 顺便说一句,我运行非Spring启动应用程序 这是我的模板: <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>Getting Started: Serving Web Content</title> <meta http-equiv="

在将ELEAF模板映射到Spring控制器时遇到问题。 顺便说一句,我运行非Spring启动应用程序

这是我的模板:

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Getting Started: Serving Web Content</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div><p><b>Search and modify garage data</b></p></div>
<div>
    <p>Available places are:</p>
    <p th:text="${places}"></p>
</div>
<h3>Select option:</h3>
<br>
<p class="header">add extra places to garage:</p>
<div>
    <form method="post" >
        <input type="text" name="numberOfPlaces" placeholder="add places">
    </form>
</div>
<br>
<p class="header">book chosen place for the specific date:</p>
<div>
    <form method="post" action="setDate">
        <input type="text"  name="id_to_book" placeholder="enter the id of Place you want to book:">
        <input type="text" name="date_to_set" placeholder="enter the date to book(YYYY-MM-DD):">
        <button type="submit" placeholder="submit">submit</button>
    </form>
</div>
<br>
<div>
    <button class="button" onclick="document.location='/'">Go to main menu </button>
</div>
</body>
</html>
表单“setDate”的提交按钮导致404错误:

说明源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式


同时,第一个表单可以正常工作,我可以添加新的实体并表示它们。我相信我在用controller的方法绑定post表单时有一些错误,但在哪里没有胶水。

在表单中添加了“操作”的完整路径后,它已被修复:

放置菜单/设置日期。 尽管我仍然没有意识到类anotation的价值,因为我仍然必须手动将其添加到映射中

方法级映射附加到类级映射中。因此,表单需要
th:action=“@{/place\u menu/setDate}”
是正常的。
@Controller
@RequestMapping("/place_menu")
public class PlaceMenuController {

    @Autowired
    private PlaceController placeController;


    @GetMapping
    public String showPlaces(ModelMap model){
     model.put( "places", this.placeController.getPlaces() ) ;
    return "place_menu";
    }

    @PostMapping()
    public String add(@RequestParam(required = false) Integer numberOfPlaces , ModelMap model){
        this.placeController.addPlaces( numberOfPlaces  );
        model.put( "places" ,this.placeController.getPlaces())    ;
      return "place_menu";
    }
    @PostMapping ("/setDate")
    public String setDate(@RequestParam(required = false) UUID id_to_book, @RequestParam(required = false) LocalDate date_to_set, ModelMap model) {
        this.placeController.setPlaceForDate( id_to_book,date_to_set);
        model.put( "places" ,this.placeController.getPlaces())    ;
        return  "place_menu";
    }
}