我想将busID和UserID插入连接表中。我从类静态变量获取了userID。
@GetMapping(path = "/busschedule/add")
public String createBus(Model model) {
model.addAttribute("bus", new BusSchedule());
return "edit";
}
@GetMapping(path = "/busschedule/edit/{busID}")
public String editBusSchedule(Model model, @PathVariable(value = "busID") long busID) {
model.addAttribute("bus", busRepository.findById(busID));
return "edit";
}
@GetMapping(path = "/busschedule/edit/{busID}/{userID}")
public String AddBustoAccount(Model model, @PathVariable(value = "busID") long busID,@PathVariable(value = "userID") long userID) {
model.addAttribute("bus", busRepository.findById(busID));
return "redirect:/busschedule";
}
第一个是我创建总线的方式,第二个是我编辑总线的方式和
第三种是我试图将其插入到联接表中但是迷路了。我必须在存储库中手动创建此查询吗?