Skip to content

Instantly share code, notes, and snippets.

@taywils
Created November 10, 2013 05:17
Show Gist options
  • Save taywils/7394124 to your computer and use it in GitHub Desktop.
Save taywils/7394124 to your computer and use it in GitHub Desktop.
spark_blog_step_2_1
get(new Route("/article/read/:id") {
@Override
public Object handle(Request request, Response response) {
Integer id = Integer.parseInt(request.params(":id"));
StringBuilder html = new StringBuilder();
for(Article article : HelloSpark.articles) {
if(id.equals(article.getId())) {
html.append("<a href='/'>Home</a>").append("<p />")
.append("Title: ").append(article.getTitle()).append("<br />")
.append(article.getCreatedAt())
.append("<p>").append(article.getContent()).append("</p>");
break;
}
}
return html.toString();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment