Created
November 10, 2013 05:17
-
-
Save taywils/7394124 to your computer and use it in GitHub Desktop.
spark_blog_step_2_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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