1 当使用left join左连连接,sql语句为
select t from SecondPage t left join t.rightNavbar n where 1=1
页面中出现了部分空行的情况,上述语句返回的list集合为
DataGrid dataGrid = new DataGrid();
List<SecondPage> list=secondPageDao.find(model, paging);dataGrid.setRows(list);
dataGrid.setTotal(secondPageDao.count(model));
return dataGrid;
遍历list的值,发现list里边的每一项都是有值的,我就没有理解,为什么直接把listset到row中,页面上就是有空格存在,但是我加了下面代码后解决了这个问题,如果有经验的朋友欢迎提供说明
DataGrid dataGrid = new DataGrid();List<SecondPage> list=secondPageDao.find(model, paging);Iterator<SecondPage> it = list.iterator();/**解决空格的问题,前台取不到值**/List<SecondPage> listCopy = new ArrayList<SecondPage>();while (it.hasNext()) {SecondPage s = (SecondPage) it.next();SecondPage copy = new SecondPage();BeanUtils.copyProperties(s, copy);listCopy.add(copy);}/**结束**/dataGrid.setRows(list);dataGrid.setTotal(secondPageDao.count(model));return dataGrid;