赞
踩
java.lang.IllegalStateException: Optional long parameter 'id' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
// 根据id查询列表
this.findByParentId=function(parentId){
return $http.get('../itemCat/findByParentId.do?parentId='+parentId);
}
//搜索
$scope.findByParentId=function(parentId){
alert(parentId);
itemCatService.findByParentId(parentId).success(
function(response){
$scope.list=response;
}
);
}
//根据id查询列表数据
public List<TbItemCat> findByParentId(Long id);
@Override
public List<TbItemCat> findByParentId(Long id) {
System.out.println(id);
TbItemCatExample example = new TbItemCatExample();
Criteria criteria = example.createCriteria();
criteria.andParentIdEqualTo(id);
return itemCatMapper.selectByExample(example);
}
// 根据id查询列表
@RequestMapping("/findByParentId")
public List<TbItemCat> findByParentId(long id) {
System.out.println(parentId);
return itemCatService.findByParentId(parentId);
}
检查发现后端controller参数是long,改成包装类Long,发生如下报警
java.lang.RuntimeException: Value for parentId cannot be null
将id输出运行,输出为null,检查参数,发现参数名错误……..与get请求提交不一致
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。