我想请问一下关于web传值的问题,代码我贴出来,求大神指点一下
前端:
查看
/c:if
跳转页面的数据接口(跳转到这个页面,显示数据):
table.render({
elem: '#contactTable'
, height: "auto"
, url: 'contacts?groupId=${groupId}' //数据接口
, cols: [[ //表头
{field: 'realName', title: '姓名', width:'8%'}
, {field: 'duty', title: '职务', width:'8%'}
, {field: 'mobiles', title: '手机号', width:'28%'}
, {field: 'emails', title: '邮箱', width:'29%'}
, {field: 'gmtCreate', title: '添加时间', width:'12%', templet: '
Group group = groupService.find(groupId);
mv.addObject("group", group);
mv.addObject("groupId", groupId);
mv.addObject("pageSize", Pages.CONTACT_PAGE_SIZE);
return mv;
}
主要的问题就是再后端钟获取不到groupId的值,这样页面就没办法进行跳转
url: 'contacts?groupId=${groupId}' url是这个,后台是这个@GetMapping("/contact/index"),不会404吗,还有你的地址栏上的参数参数传递了没
url: 'contacts?groupId=${groupId}' //数据接口
这里要和
@GetMapping("/contact/index")
这里的值一致,在前面加上你的项目地址
url: ${pageContext.request.contextPath}+'/contact/index?groupId=${groupId}' //数据接口
debug看下前端传值给后端没有
值不一致,web开发要注意一些小细节
直接打开浏览器看看有没有数据返回,就行了
groupId={{d.id}},这里为什么是两个大括号啊,是不是写错了。
1.public ModelAndView index(**@PathVariable** Integer groupId){这个注解需要加么?
2.这个路径对不对?