Hi everyone I usually use @PathVariable
, but for this case, I don't know why it doesn't work.
menu.jsp:
<a href="<c:url value= '/admin/myCart/1/${idproducts}' />">Panier</a>
Controller:
@RequestMapping(value = "/admin/viewProduct/{ref}", method = RequestMethod.GET)
public String getProduit(@PathVariable("ref") int ref, Model model) {
**model.addAttribute("idproducts",this.orderedProductService.getIdOrderedProductsByclient(1));**
model.addAttribute("produit", this.produitService.getProduitById(ref));
return "menu";
}
@RequestMapping(value= "/admin/monPanier/{idproducts}", method = RequestMethod.GET)
public String myCart( @PathVariable("idproducts") String idproducts,Model model) {
return mycart;
}
So menu.jsp get {idproducts}
(which is a String containing ids separated by " / ", for example: idproducts = 5/6/7), but I don't know why @PathVariable("idproducts")
doesn't work. The error is:
No mapping found for HTTP request with URI [/SpringMVCHibernate/admin/myCart/5/6/7/]
You have URL defined as,
But in
controller
there is no such mapping defined with/admin/mycart/1
It is defined to be with
/admin/mycart
,So try to fix your
controller
as follows,