在java中替换URL路径参数

在java中替换URL路径参数,java,rest,url,replace,Java,Rest,Url,Replace,我需要使用URL路径参数对服务进行restful web服务调用 http://localhost:8080/api/jsonws/user/get-user-by-email-address/company-id/{company-id}/email-address/{email-address} 在进行服务调用时,用参数替换参数的最佳实践/有效方式应该是什么?为了替换字符串中的多个字符串,最后使用 import com.liferay.portal.kernel.util.

我需要使用URL路径参数对服务进行restful web服务调用

http://localhost:8080/api/jsonws/user/get-user-by-email-address/company-id/{company-id}/email-address/{email-address}

在进行服务调用时,用参数替换参数的最佳实践/有效方式应该是什么?

为了替换字符串中的多个字符串,最后使用

        import com.liferay.portal.kernel.util.StringUtil;

        String[] searchList={"{company-id}","{email-address}"};
        String[] replList={groupId,userEmail};
        url=StringUtil.replace(url, searchList, replList);

这里的
StringUtil
是门户库的一部分,而类似的类
StringUtils
也可以使用,它是Apache Commons库的一部分。

用实际值替换参数字符串是显而易见的。没有这样好的或不好的做法。嗯,我在寻找一些特定于Rest的方法,以最有效的方式执行此操作。特定于Rest的方法你是什么意思?REST不是关于替换URL路径参数的。谢谢你的澄清。明白你的意思了!