您一直试图让我的“开始拍卖”按钮链接到控制器类而没有运气。
这是jsp页面中的按钮 -
<button type="button" class="btn btn-success btn-lg"><a href="../aucConfirm/${newAuction.idauction}/start" >Start Auction</a></button>
这两个控制器方法,confirmAuction有一个model.AddAttribute行 -
@RequestMapping(value = "/aucConfirm/{idauction}", method = RequestMethod.GET)
public String confirmAuction(@PathVariable(value = "idauction") int idauction, Model model, HttpServletRequest request) {
AuctionItem addAuction = (AuctionItem) aucRepository.findOne(idauction);
model.addAttribute("newAuction", addAuction);
model.addAttribute("startAction", addAuction.getIdauction() + "/start");
return "aucConfirm";
}
@RequestMapping(value = "/aucConfirm/{idauction}/start", method = RequestMethod.GET)
public String startAuction(@PathVariable(value = "idauction") int idauction, RedirectAttributes redirect) {
AuctionItem addAuction = (AuctionItem) aucRepository.findOne(idauction);
List<Image> imageList = (List<Image>) imageRepository.findByidauction(idauction);
addAuction.setMainImage(imageList.get(0).getImagepath());
addAuction.setActive(true);
aucRepository.save(addAuction);
return "redirect:/listing/" + idauction;
}
任何人都知道为什么这个按钮不起作用?它什么都不做,甚至没有错误信息。