HTTP Status 400 - Required Long parameter 'id' is not present

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 getItemCatList(@RequestParam(value="id")Long parentId){
List list = itemCatService.getItemCatList(parentId);
return list;
}
}
访问的URL:http://localhost:8080/taotao-manager-web/item/cat/list
当使用@RequestParam绑定参数时会出现这种情况,第一次访问时无id,需要为其加上默认的id,即@RequestParam("value="id",defaultValue="0")

你可能感兴趣的:(HTTP Status 400 - Required Long parameter 'id' is not present)