Remove “/” from api call when optional parameter is null

混江龙づ霸主 提交于 2019-12-06 02:51:38

Looking at your reference, have you tried this:

@Path("userid/{userid}/companyid/{companyid}{optparam:(/[^/]+?)*}")
public Response getLocation(
        @PathParam("userid") int userid,
        @PathParam("companyid") int companyid,
        @PathParam("optparam") String optparam) {
    String[] params = parseParams(optparam);
    ...
}

private String[] parseParams(String params) {
    if (params.startsWith("/")) {
        params = path.substring(1);
    }
    return params.split("/");
}

That should work, giving you all the parameters in a single array.

EDIT: I have updated the search string and verified it on a local install.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!