HTTP Status 400 - Required Long parameter 'id' is not present
type Status report
message Required Long parameter 'id' is not present
description The request sent by the client was syntactically incorrect (Required Long parameter 'id' is not present).
Apache Tomcat/6.0.29
代码如下:
@Controller
@RequestMapping("/item/cat")
public class ItemCatController {
@Autowired
private ItemCatService itemCatService;
@RequestMapping("/list")
@ResponseBody
public List<EasyUITreeNode> getItemCatList(@RequestParam(value="id")Long parentId){
List<EasyUITreeNode> list = itemCatService.getItemCatList(parentId);
return list;
}
}
@RequestMapping("/item/cat")
public class ItemCatController {
@Autowired
private ItemCatService itemCatService;
@RequestMapping("/list")
@ResponseBody
public List<EasyUITreeNode> getItemCatList(@RequestParam(value="id")Long parentId){
List<EasyUITreeNode> list = itemCatService.getItemCatList(parentId);
return list;
}
}
访问的URL:http://localhost:8080/taotao-manager-web/item/cat/list
当使用@RequestParam绑定参数时会出现这种情况,第一次访问时无id,需要为其加上默认的id,即@RequestParam("value="id",defaultValue="0")