1.js页面:返回json填充HTML部分代码
<a class='byCard' href="+path+"/static/toCardView/"+ data.newList[i].cId + "/"+data.newList[i].gid+"/"+data.newList[i].titleImg+"/"+data.newList[i].cName+"/"+data.newList[i].iniPrice+"/"+data.newList[i].price+"/"+data.newList[i].number+"/"+data.newList[i].praiseRate+"/"+data.newList[i].cInfo+"/"+data.newList[i].gName+">立刻购买</a>
2.@Controller后台接收:
/**
* 跳转到点卡详情页面
* @param cid
* @param gid
* @param titleImg
* @param cName
* @param iniPrice
* @param price
* @param number
* @param praiseRate
* @param cInfo
* @param gName
* @param model
* @return
*/
@RequestMapping(value = "/static/toCardView/{cid}/{gid}/{titleImg}/{cName}/{iniPrice}/{price}/{number}/{praiseRate}/{cInfo}/{gName}")
public String toCardView(@PathVariable("cid") int cid,
@PathVariable("gid") int gid,
@PathVariable("titleImg") String titleImg,
@PathVariable("cName") String cName,
@PathVariable("iniPrice") Double iniPrice,
@PathVariable("price") Double price,
@PathVariable("number") int number,
@PathVariable("praiseRate") Double praiseRate,
@PathVariable("cInfo") String cInfo,
@PathVariable("gName") String gName,
Model model){
Cards cards=new Cards(cid,cName,titleImg,iniPrice,price,cInfo,praiseRate,number,gid,gName);
List<PraiseRate> praiseRateList=cardsBiz.searchPraiseRate(cards.getcId());
List<CardPcitrue> pcitrueList=cardsBiz.searchByCid(cards.getcId());
model.addAttribute("cards",cards);
model.addAttribute("praiseRateList",praiseRateList);
model.addAttribute("pcitrueList",pcitrueList);
return "cardView";
}
这样后台就接收到了一个完整得对象,少了一次查询