How to add the java variable value in the Configuration util String -
I am writing Java code for calling ROR APIs ..
I have written Java code to get all the blogs by开发者_JS百科
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>>() {
});
}
where in my Configuration.Utilfile LIST_BLOGS will be http://localhost:3000/api/blogs.xml
now I trying to fetch the blogs that matches a field value for the blogs My blogs table contains a field slug so that those keyword that matches this will be returned. For this I received the input slug and now I need to append this slug with my path in the ConfigurationUTIL file LIST_BLOGS_SLUG = "http://localhost:3000/api/blogs/.xml"
how should I do this.. Below is my code for receiving the slug parameter
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>>() {
});
}
Solution by OP.
I have found the solution by keeping the string in the method
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>>() {
});
}
精彩评论