2010-09-13 30 views
1

我写Java代码调用API的ROR ..如何配置添加Java变量值util的字符串 -

我已经写Java代码通过

public List<BlogBean> getBlogsXml() { 

    return webResource.path(ConfigurationUtil.LIST_BLOGS).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication) 
    .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<List<BlogBean>>() { 
}); 
    } 

从哪里得到的所有博客在我Configuration.Utilfile LIST_BLOGS将http://localhost:3000/api/blogs.xml

现在我试图获取,对于博客相匹配的字段值的博客 我的博客表包含一个字段塞,使那些个关键字匹配将被退回。为此,我接收到的输入蛞蝓和现在我需要这种蛞蝓追加与我在ConfigurationUTIL文件路径 LIST_BLOGS_SLUG =“http://localhost:3000/api/blogs/的.xml”

我应该怎么做..下面是我的代码,用于接收蛞蝓参数

public List<BlogBean> showBlog_slug(String slug) 
{ 
    return webResource.path(ConfigurationUtil.LIST_BLOGS_SLUG).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication) 
    .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<List<BlogBean>>() { 
    }); 
} 
+0

我提出你的解决方案,以一个社区的答案的解决方案。 – 2017-08-29 17:19:12

回答

0

解决方案由OP。

我发现通过保持字符串中的方法

public List<BlogBean> showBlog_slug(String slug){ 
    final string LIST_BLOGS_SLUG="mypath/api/blogs/"+slug+".xml" 
    return webResource.path(LIST_BLOGS_SLUG).header(ConfigurationUtil.AUTHENTICATION_HEADER, authentication) 
    .accept(MediaType.APPLICATION_XML_TYPE).get(new GenericType<List<BlogBean>>() { 
    }); 
}