Spring mvc找不到post方法的表示



在将Thymelaf模板映射到Spring控制器时出现问题。我运行非Spring引导应用程序btw.

这是我的模板:

<!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>

和控制器:

@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";
}
}

表单"setDate"的提交按钮导致404错误:

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

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

在以形式向"操作"添加完整路径后,它已被修复

place_menu/setDate。尽管我仍然没有意识到class anotation的价值,因为我仍然需要手动将其添加到映射中