前台页面需要带参数跳转页面
<a href='/homapage/toParticulars?id=1'>
在controller层实现代参跳转
@RequestMapping("toParticulars")
public ModelAndView toParticulars(Commodity commodity){//参数传入对象
ModelAndView mav = new ModelAndView();
//要跳转的页面
mav.setViewName("homepage/Product");
//传入对象
mav.addObject("commodity",commodity);
return mav;
}
另一页面接收参数
可以设置一个隐藏域,将参数传入
<input type="hidden" name="id" th:value="*{commodity.id}" />
当需要用到参数时,可以这样取参
<script>
var id= $("input[name='id']").val();
</script>