我在SpringMVC中有一个url路径模式,如下所示:
/person/{personId}/address/{addressId}我有personId =2和addressId =3,我有一个简单的方法来生成
/person/2/address/3 在SpringMvc中使用实用方法?
发布于 2016-02-22 14:07:06
看看UriTemplate类。您可以从URL构建自己的UriTemplate,然后展开模板变量。
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("booking", "42");
uriVariables.put("hotel", "1");
System.out.println(template.expand(uriVariables));https://stackoverflow.com/questions/35545665
复制相似问题