2010-09-13 31 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>>() { 
    }); 
}