Created
November 27, 2013 04:11
-
-
Save taywils/7670579 to your computer and use it in GitHub Desktop.
spark_view_step_4
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 FreeMarkerRoute("/article/read/:id") { | |
@Override | |
public Object handle(Request request, Response response) { | |
Integer id = Integer.parseInt(request.params(":id")); | |
Map<String, Object> viewObjects = new HashMap<String, Object>(); | |
viewObjects.put("templateName", "articleRead.ftl"); | |
for(Article article : HelloSpark.articles) { | |
if(id.equals(article.getId())) { | |
viewObjects.put("article", article); | |
break; | |
} | |
} | |
return modelAndView(viewObjects, "layout.ftl"); | |
} | |
}); | |
get(new FreeMarkerRoute("/article/update/:id") { | |
@Override | |
public Object handle(Request request, Response response) { | |
Integer id = Integer.parseInt(request.params(":id")); | |
Map<String, Object> viewObjects = new HashMap<String, Object>(); | |
viewObjects.put("templateName", "articleForm.ftl"); | |
for(Article article : HelloSpark.articles) { | |
if(id.equals(article.getId())) { | |
viewObjects.put("article", article); | |
break; | |
} | |
} | |
return modelAndView(viewObjects, "layout.ftl"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment