@PathVariable接受的参数可能为null

@RequestMapping(value = {"/getTreeNode/{id}","/getTreeNode"}, produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("查询树节点接口")
    public List<ModelTreeDto> getTreeNode(@PathVariable(value = "id",required=false ) String id) throws Exception {
        return modelTreeServiceImpl.getTreeNode(id);
    }

1.加上required=false,

2.在mapping上加上"/getTreeNode",这样可以使required=false生效,当没有传参时会请求/getTreeNode

猜你喜欢

转载自blog.csdn.net/lyf_ldh/article/details/83619658